Servlet PrintWriter输出中文乱码解决方法

加入下面代码即可 ,注意PrintWriter获取输出流得在

        request.setCharacterEncoding("UTF-8");//对返回浏览器数据没啥用,不过建议添加
        respsonse.setHeader("Content-type", "text/html;charset=UTF-8");//告知浏览器编码方式;
        response.setCharacterEncoding("UTF-8");
        //向前台的页面输出结果的输出流
        PrintWriter out=response.getWriter();
发布了242 篇原创文章 · 获赞 13 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/qq_41813208/article/details/103775619