All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
ajax中文乱码解决方案_[AJAX教程]

Writer: 归海一刀 Article type: Programming skills(编程技巧) Time: 2014/3/16 2:51:32 Browse times: 245 Comment times: 0

ajax中文乱码解决方案_[AJAX教程]


Head photo

Go homepage
Upload pictures
Write articles

ajax中文乱码解决方案_[AJAX教程] 说明一下我用的是JAVA,所以以下的内容都是其于JAVA的AJAX与服务器通信是用XML的所以编码方式为UTF-8我所有的页面都用的是GB2312的所以在与服务器通信时出现在乱码首先从服务器向客户端(就是浏览器嘛)发送数据时就好解决了直接在页面上面加上 <%@ page contentType="text/html;charset=GB2312%>如果是用Servlet就加response.setContentType("text/html;charset=gb2312");
request.setCharacterEncoding("gb2312");还有一个更好的方法就是在加一个filter在其中加入response.setContentType("text/html;charset=gb2312");
request.setCharacterEncoding("gb2312");一切都解决了再说一下从客户端上传数据,就必须在服务端进行编码转换String param = request.getParamter("param");param = new String(param.getBytes("ISO-8859-1"),"GB2312"); 现在就都是中文的了。




There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.