One reason why

The default character set of Windows 10 is GBK, which is read by Java VMS when they start up. For our project, it’s usually set to UTF-8. Tomcat is also dependent on JDK in nature, so Chinese garbled characters will naturally appear.

2 to solve

Modify the catalina.bat file in the bin directory of the Tomcat installation directory.

set "JAVA_OPTS=%JAVA_OPTS% -Dfile.encoding=UTF-8"
Copy the code

The -d

=

syntax sets system properties, which are key-value pairs. File. encoding is set to UTF-8.


It would be better to write all your code in English so there are no coding problems, but this is only for new projects.