The problem of garbled characters in Javaweb
In the first contact Javaweb encountered garbled problem, the following is the solution I have encountered these problems
1. 页面乱码(jsp) 1. 在页面最前方加上 <%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%>2. 读取数据时乱码 (servlet) 1. 在request.getParameter("name");前面加上 request.setCharacterEncoding("utf-8");3. 返回数据时乱码 (servlet) 1. 在response.getWriter().print(content);前加上 response.setHeader("Content-type", "text/html;charset=UTF-8"); response.setCharacterEncoding("UTF-8");
Note: The above solution is the solution I encountered when the problem, if it does not work or if there are other circumstances, can refer to http://blog.csdn.net/chenghui0317/article/details/10299103, Write the situation quite a lot of this article for the original, if you need to reprint please specify http://www.cnblogs.com/zhuchenglin/p/8098064.html
Garbled problem in Javaweb (written on first contact)