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>"); }

 

posted @ 2016-04-14 21:18  Wcy100  阅读(161)  评论(0编辑  收藏  举报