public class ResoponseServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//设置服务器字符集为utf-8
resp.setCharacterEncoding("utf-8");
//通过响应头。设置浏览器也使用utf-8
resp.setHeader("Content-type","text/html;charset=UTF-8");
PrintWriter writer = resp.getWriter();
writer.write("lij李建超");
}
}