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

jquery-ajax从后台返回值为中文时乱码解决办法

2012-06-27 
jquery-ajax从后台返回值为中文时乱码解决方法前提是该项目前台jsp编码为gbk,过滤器也设置为gbkfilterf

jquery-ajax从后台返回值为中文时乱码解决方法
前提是该项目前台jsp编码为gbk,过滤器也设置为gbk

  <filter>    <filter-name>SetCharacterEncodingFilter</filter-name>    <filter-class>eoffice.servlet.SetCharacterEncodingFilter</filter-class>    <init-param>      <param-name>encoding</param-name>      <param-value>GBK</param-value>    </init-param>  </filter>


后台java为
    、   JSONArray  resultList=JSONArray.fromObject(innerArticleColumnList);    response.setContentType("text/json;charset=GBK");       response.setHeader("Cache-Control", "no-cache");   out.print(resultList.toString());

怎么滴也差不错到底哪步错了,后来网上终于找到答案,
     out=response.getWriter(); //输出中文,这一句一定要放到response.setContentType("text/xml;charset=utf-8"),  response.setHeader("Cache-Control", "no-cache")后面,否则中文返回到页面是乱码 

非常感谢这位大大。http://penghuaiyi.iteye.com/blog/470325

热点排行