调试手机WAP站,传递多个参数到Controller层,结果发现mesage参数为空,而其他参数却不为空。
@RequestMapping("msgbox")
public String msgbox(Model model, boolean success, String message, String hrefUrl, String hrefText)
{
model.addAttribute("success", success);
model.addAttribute("message", message);
model.addAttribute("hrefUrl", hrefUrl);
model.addAttribute("hrefText", hrefText);
return WAP_VM + "wap_msg_box.vm";
}在对应的前端页面,用alert语句打印message参数,显示正常。
function showDetails(detailId) {
//...
var url = "/wap/msgbox"
+"?success=true&message="+$("#detailsDiv").html()+"&hrefUrl=&hrefText=确定";
window.location=encodeURI(url);
}最开始怀疑是参数太长,被截断,测试message为0123...,长度从200,400,1000,3000...不等,都没有问题。
注意到有一个错误信息:org.apache.tomcat.util.http.Parameters processParameters警告。
考虑其他原因:
1. 含有%字符,没有特殊处理;
2. 直接对URL进行编码,查询JavaScript直接就有URL编码函数:
window.location=encodeURI(url);
本文探讨了在调试手机WAP站点时遇到的问题:传递到Controller层的多个参数中,特定参数出现丢失现象。文章详细记录了问题的排查过程,包括对URL长度、特殊字符处理及编码方式的考虑。

4009

被折叠的 条评论
为什么被折叠?



