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>"); }
时间: 2024-12-27 07:55:55