先在jsp編碼,再在action中解碼
encodeURI(encodeURI("中文"))編碼
URLDecoder.decode(request.getParameter("參數名"),"UTF-8");完成解碼。
例如: url:"qtypenums.action?typeid=<s:property value='typeid' escape='false'/>&qmobile=<s:property value='qmobile' escape='false'/>&qname="+encodeURI(encodeURI('<s:property value='qname' escape='false'/>'))+"&qattr1="+encodeURI(encodeURI('<s:property value='qattr1' escape='false'/>'))+"&qattr2="+encodeURI(encodeURI('<s:property value='qattr2' escape='false'/>'))+"&qattr3="+encodeURI(encodeURI('<s:property value='qattr3' escape='false'/>')),
在action中解碼
String qname=this.getQname();
String qattr1=this.getQattr1()==null?"":this.getQattr1();
String qattr2=this.getQattr2()==null?"":this.getQattr2();
String qattr3=this.getQattr3()==null?"":this.getQattr3();
String qname1="";
String qattr11="";
String qattr21="";
String qattr31="";
try{
qname1=URLDecoder.decode(qname,"UTF-8");
qattr11=URLDecoder.decode(qattr1,"UTF-8");
qattr21=URLDecoder.decode(qattr2,"UTF-8");
qattr31=URLDecoder.decode(qattr3,"UTF-8");
}catch(Exception w){}