Servlet PrintWriter output Chinese garbled solution

Was added to the code below, note that the output stream obtained in the obtaining PrintWriter

        request.setCharacterEncoding("UTF-8");//对返回浏览器数据没啥用,不过建议添加
        respsonse.setHeader("Content-type", "text/html;charset=UTF-8");//告知浏览器编码方式;
        response.setCharacterEncoding("UTF-8");
        //向前台的页面输出结果的输出流
        PrintWriter out=response.getWriter();

 

Published 242 original articles · won praise 13 · views 10000 +

Guess you like

Origin blog.csdn.net/qq_41813208/article/details/103775619