当前位置: 代码迷 >> J2EE >> Ajax的responseText返回乱码该怎么解决?试过N种方法无效!求救
  详细解决方案

Ajax的responseText返回乱码该怎么解决?试过N种方法无效!求救

热度:351   发布时间:2016-04-22 03:36:47.0
Ajax的responseText返回乱码该如何解决?试过N种方法无效!求救!
服务器端:
response.setCharacterEncoding("UTF-8");
response.setHeader("Charset","UTF-8");
System.out.println(request.getCharacterEncoding());
System.out.println(response.getCharacterEncoding());
控制台打出:
UTF-8
ISO-8859-1
 
前台jsp页面:
<%@ page contentType="text/html; charset=UTF-8" language="java" isELIgnored="false" errorPage=""%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%response.setHeader("Charset","UTF-8");%>

responseText返回的就是乱码,response.setCharacterEncoding("UTF-8");response.setHeader("Charset","UTF-8");这2句话好像根本没有反应,为什么呢?请高手指点!感谢!

------解决方案--------------------
传byte[]不要传String``
  相关解决方案