服务器环境:
Jetty 6.1.7
ExtJS-2.2
json-lib 2.2.2
使用Jetty服务器用JSON进行数据传递,发现中文字符都呈现????状乱码,response的头设置为:
response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Expires", "0");
response.setHeader("Content-Type", "text/xml; charset=utf-8");
PrintWriter out = response.getWriter();
后为解决此问题添加了一行制定编码格式的语句,response.setCharacterEncoding("utf-8"); 解决问题时的代码:
response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Expires", "0");
response.setHeader("Content-Type", "text/xml; charset=utf-8");
response.setCharacterEncoding("utf-8");
PrintWriter out = response.getWriter();