1.jsp页面需要设置编码格式为utf-8
1 <%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="utf-8" %>
2 <%request.setCharacterEncoding("utf-8");%>
3
4 <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
2.jsp页面form表单提交数据方式改为post,为get会有类似英文的乱码
3.设置项目的各种编码格式,点击左上角Files——>settings,搜索file encoding,选择utf-8
4.设置request和response编码(一定是获取数据之前)
1 response.setContentType("text/html;charset=utf-8");
2 request.setCharacterEncoding("utf-8");
3 response.setCharacterEncoding("utf-8");
5.设置数据库字符集
6.检查tomcat字符集
添加tomcat服务器时,在VM中添加&characterEncoding=UTF-8,然后apply