Option One:
one、tomcat—->Edit Configurations
- Select Startup/Connection—->check Pass environment variables—->click the + sign
- Fill in: Name:JAVA_TOOL_OPTIONS; Value:-Dfile.encoding=UTF-8; Click Apply
- Select Server—->fill in -Dfile.encoding=UTF-8 in VM options—->click Apply; restart tomcat to see if the problem is successfully solved.
Option II:
1. Modify the garbled encoding of the editor. This is easy to solve. Change all of them into UTF-8. The path is file->settings->editor->file Encodings.
- Solve console garbled code
Add -Dfile.encoding=UTF-8 in tomcat->Edit Configurations->VM options
- Operating environment
existtomcat->Edit Configurations->Startup/Connection
-—>Tick Pass environment variables—->Click the + sign
Add the following code:
JAVA_OPTS -Dfile.encoding=UTF-8
JAVA_TOOL_OPTIONS -Dfile.encoding=UTF-8
In our local debugging, we usually choose debug directly.
- Change the encoding.xml under the .idea folder of the project
Change all encoding formats inside to UTF-8
- Modify the two configuration files in the bin directory of the idea installation directory.
Find the two files in the bin directory of the idea installation directory as shown below: 1.idea.exe.vmoptions 2.idea64.exe.vmoptions. Open them with an editor and add -Dfile.encoding=UTF-8 at the end of the file.
The last step is to restart idea, restart tomcat, and the problem should be solved!