Solve the garbled characters in the Tomcat server console in IDEA

Solve the garbled characters in the Tomcat server console in IDEA

Description of the problem: When we use the idea editor to deploy web programs to the tomcat server, when we run tomcat, the server output garbled content in the console. This problem may be caused by inconsistent encoding. In IDEA, if the encoding method of the project is inconsistent with the encoding method of the Tomcat server, the output content of the server may be garbled.

This problem may bring inconvenience to development and debugging, because the garbled output is difficult to read, and it is impossible to intuitively understand the operation of the server. At the same time, if the garbled code problem is not dealt with in time, it may affect the normal operation of the system, thereby increasing the difficulty of development and maintenance.

insert image description here

Solution

We can solve it by modifying the relevant configuration of idea.
Set the project encoding method: In IDEA, you can set the encoding method in the project settings to ensure that it is consistent with the encoding method of the Tomcat server.

Set the encoding method of Tomcat: In the Tomcat configuration file, you can also set the encoding method of the server to ensure that it is consistent with the encoding method of the project.

Modify the IDEA console encoding method: If the above two methods cannot solve the problem, you can try to modify the IDEA console encoding method so that it can correctly display the content output by the server.

Modify the encoding method of the output content: If the content output by the server is garbled, you can try to modify the encoding method of the output content to convert it to the correct encoding method.

1. Modify the encoding method in Settings -->Editor to utf-8

Specific steps are as follows:
insert image description here
insert image description here
insert image description here

2. Modify the VM virtual machine configuration

The specific steps are as follows: Add the following code under idea64.exe.vmoptions,
insert image description here
insert image description here

3. Add the code added in the previous step to the tomcat server VM configuration

Specific steps are as follows:
insert image description here
insert image description here

4. Final tip.

Remember to click OK in all the above steps to save your configuration. After completing the above steps, the console garbled problem can be solved.

Guess you like

Origin blog.csdn.net/hjjshua/article/details/130511700