Idea unified setting code to UTF-8 code and solution of Tomcat garbled code

Modify project space code

File-> Settings-> Editor-> File encodings
check the bottom box

Modifying the relevant configuration in Tomcat

Step 1: modify Tomcat configuration file and add UTF-8 code

Change the service.xml configuration in Tomcat's conf folder to add URIEncoding="UTF-8", as follows.

<Connector port="8080" protocol="HTTP/1.1" ​ connectionTimeout="20000" ​ redirectPort="8443" URIEncoding="UTF-8"/>

It was found that the start-up condition remained unchanged

Step 2: change the idea configuration and set the encoding to UTF-8

Refer to the above method

Step 3: modify the parameters in logging. Properties under conf of Tomcat

Change java.util.logging.ConsoleHandler.encoding = GBK

to

java.util.logging.ConsoleHandler.encoding = UTF-8

Read More: