码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2014-11-21 10:24:53      阅读:222      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   ar   color   os   sp   for   

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

 

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”.

 

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

标签:style   blog   http   io   ar   color   os   sp   for   

原文地址:http://www.cnblogs.com/linl/p/4112103.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!