Engineering garbled
Open File-Setting, File Encodings find this option, set the encoding to encode your project, usually UTF-8, as shown below (red box in place), and then rebuild it again, basically on the line
The implementation of the main function, the console garbled
Also open setting, find Build, Execution, Deployment> Compiler> Java Compiler, set the Additional command line parameters option -encoding utf-8, and then the next rebuild, re-run
When you run tomcat, console garbled
1) Open the Run / Debug Configuration, select your tomcat
2) Then Server> VM options to -Dfile.encoding = UTF-8, restart tomcat
supplement:
tomcat configuration file: In tomcat / conf directory, set logging.properties
Other garbled
Whether 1) Database garbled data
View database encoding type
show variables like ‘character%’
character_set_client utf8
character_set_connection utf8
character_set_database utf8
character_set_filesystem binary
character_set_results utf8
character_set_server utf8
character_set_system utf8
character_sets_dir /aebiz/soft/mysql/share/charsets/
2)jsp乱码
查看代码中是否添加下面代码
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
3)request和response
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
参考: