时间:2021-07-01 10:21:17 帮助过:1人阅读
function show(next,id,realName){
document.forms['f2'].action="usersearchNextPage?next="+next+"&id="+id+"&realName="+encodeURI(encodeURI(realName));
document.forms['f2'].submit();
}
其中 realName是中文参数。故在提交的URL中将realName转码两次。encodeURI(encodeURI(realName))
Action中:接收中文参数时解码。用:java.net.URLDecoder.decode(realName,"UTF-8");
如:
代码如下:
String realName = ServletActionContext.getRequest().getParameter("realName");
try {
realName = java.net.URLDecoder.decode(realName,"UTF-8");
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
}
经过上述处理,问题解决。