ajax 提交乱码问题。。

js :
var url="chatlogs!saveLogs.action?formInfo.FFROMUSER="+encodeURI(encodeURI(fromUser))+"&formInfo.FTOUSER="+encodeURI(encodeURI(name))+"&formInfo.FCONTENT="+encodeURI(encodeURI(content));
java:
this.getResponse().setContentType("text/html;charset=utf-8");
this.getResponse().setCharacterEncoding("utf-8");
content = java.net.URLDecoder.decode(content,"UTF-8");
-------------------------------------------------------------------------------------------------------
其他方法:
统一使用UTF-8的模式
jh_soft (初级程序员) 2009-07-14
指定页面的编码方法统一为utf-8
rain2005 (高级程序员) 2009-07-14
在request.getParameter("username")之前先request.setCharacterEncoding("UTF-8"); 

取得时候Strings=newString(request.getParameter("username").getBytes("UTF-8"),"GBK");

最好页面的编码都设置为utf-8,就不需要转换了。

对酒当歌,人生几何 (初级程序员) 2009-07-15
呵呵,估计你是使用了get的方式传送的变量,那么你可以这样: 

在tomcat里面设置URIEncoding="UTF-8"

<Connectorport="8085"...URIEncoding="UTF-8"/>

然后再在程序里面加个filter就可以了

相关推荐