一、jsp页面或html页面(适用于页面乱码)
开头加入<%@ page contentType=“text/html;charset=UTF-8” language=“java” %>
二、tomcat或者idea导致的乱码(适用于控制台乱码)
1.tomcat配置
(a)在VM options框里加上 -Dfile.encoding=UTF-8
(b)添加name:JAVA_TOOL_OPTIONS value:-Dfile.encoding=UTF-8
2.idea配置
(a)在setting里面,确保三个位置都是utf-8
(b)修改idea安装目录下idea.exe.vmoptions和idea64.exe.vmoptions两个文件,后面加上-Dfile.encoding=UTF-8,然后重启idea。
三、配置字符编码过滤器
四、参考资料
【1】https://blog.csdn.net/weixin_41595700/article/details/84890883?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1.pc_relevant_paycolumn_v3&utm_relevant_index=2
【2】https://blog.csdn.net/mao1059568684/article/details/105834687?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1.pc_relevant_default&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1.pc_relevant_default&utm_relevant_index=2
【3】https://blog.csdn.net/qq_42339115/article/details/102154064?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1.pc_relevant_antiscanv2&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1.pc_relevant_antiscanv2
【4】https://www.cnblogs.com/zyboGarden/p/10406162.html