ajax和SSH请求中乱码的一些解决方法

乱码的原因无非就是两端的编码方式不同.

 

ajax方的编码

ajax无论是get还是post,都可以在content-type中设置charset为utf-8,或者beforesend中在setheader

 

SSH方的编码

1.在struts.xml中配置

<constant name="struts.i18n.encoding" value="UTF-8" />

2.在web.xml中配置encoding

 

tomcat的编码

这个也是最容易被忽略的

<Connector port="8080" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" URIEncoding=”utf-8”/>

此处添加了URIEncoding=”utf-8”.

 

posted @ 2014-11-21 09:42  程序小怪兽  阅读(284)  评论(0编辑  收藏  举报