日期:2014-05-18  浏览次数:20714 次

IE9 IE10中文乱码问题
servlet中,用newUserName = new String(newUserName_AZ.getBytes("ISO8859_1"),"utf-8");解决客户端的中文乱码,但是当浏览器为IE9以上版本时候,这个方法就不能解决中文乱码,请问,针对IE9以上的浏览器,serlvet中怎么解析乱码为正常呢?
乱码 ie9 ie10 servlet utf-8

------解决方案--------------------
把这个new String(newUserName_AZ.getBytes("ISO8859_1"),"utf-8");
变成new String(newUserName_AZ.getBytes("ISO-8859-1"),"utf-8");
试试
好像IE 不认识ISO8859_1

------解决方案--------------------
request.setCharacterEncoding("utf-8");
------解决方案--------------------
response.setCharacterEncoding("utf-8");
response.setContentType("text/html; charset=utf-8")
------解决方案--------------------
好像没有直接得客户端发送请求过来的客户端浏览器方的版本号。
------解决方案--------------------
在tomcat中,将<connector/>中设置useBodyEncodingForURI设置为true,<html/> header中添加contentType="utf8" ;
------解决方案--------------------
tomcat配置文件中的connector标签中添加URIEncoding="utf-8",这样只对get方法有效哦,或者你可以将url后面的中文通过js的encodeURI方法两次编译转化成utf-8的编码encodeURI(encodeURI(your param))
------解决方案--------------------
response.setCharacterEncoding("utf-8");
response.setContentType("text/html; charset=utf-8")