刚在群里解答了一个ajax取action产生的中文页面得到乱码的问题,感觉有必要记下来,这段代码是这么写的,输出编码为utf-8

        response.setContentType("text/html;charset=utf-8");
        response.setHeader(
"Cache-Control""no-cache");
        
try
        {
            PrintWriter pw
=new PrintWriter(new OutputStreamWriter(response.getOutputStream(),"utf-8"));
            pw.write(xmlBuf.toString());
            pw.close();
        }
        
catch(java.io.IOException e)
        {
            e.printStackTrace();
        }
  放这里,以后有用。

相关文章:

  • 2021-11-29
  • 2022-12-23
  • 2021-09-21
  • 2022-01-19
  • 2021-09-04
  • 2021-06-29
  • 2021-08-30
猜你喜欢
  • 2022-12-23
  • 2021-06-08
  • 2022-12-23
  • 2021-12-01
  • 2022-02-07
  • 2022-02-01
  • 2022-12-23
相关资源
相似解决方案