首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

jQuery乱码有关问题

2012-10-28 
jQuery乱码问题(2010-08-27记录)jQuery乱码问题:最近学习jQuery,在使用jqgrid插件时,遇到了ie乱码,firefox

jQuery乱码问题
(2010-08-27记录)jQuery乱码问题:
最近学习jQuery,在使用jqgrid插件时,遇到了ie乱码,firefox显示正常的情况:
1.检查页面编码,将页面编码设置为utf8,如下:
<meta http-equiv="content-type" content="text/html; charset=utf-8">
2.检查servlet,在doPost或doGet方法中添加如下代码:
response.setContentType("text/xml;charset=utf-8");
3.修改tomcat文件,在TOMCAT_HOME/conf/server.xml文件中增加URIEncoding=”utf8”:
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="utf-8"/>
4.在工程中新增过滤器,将编码方式设置为utf8
经过以上四步操作后,问题依旧。
5.检查ie的http header,查看contentType字段,如下:
contentType:"application/x-www-form-urlencoded"
6.检查firefox的http header,查看contentType字段,如下:
contentType:"application/x-www-form-urlencoded;charset=UTF-8"
对比5,6两步,问题出现。
7.修改jQuery-1.x.x.js文件,将
contentType:"application/x-www-form-urlencoded"改为下面的代码
contentType:"application/x-www-form-urlencoded;charset=UTF-8"
总结:其它浏览器和ie类似(同事讲的,没测),还是firefox好(严谨)。
1 楼 fhjxp 2011-06-28   根本原因不是jquery的问题,还是第4步中的filter位置不靠前没有起到作用

热点排行