Servlet中文乱码的解决方法

    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//以下两句,设置UTF-8编码,可以解决乱码 resp.setCharacterEncoding(
"UTF-8"); resp.setHeader("content-type","text/html;charset=UTF-8");
resp.getWriter().write(
"<a href="www.example.com">这是测试文本</a>"); }
原文地址:https://www.cnblogs.com/Wcy100/p/5392776.html