Tomcat console garbled under Windows

Original URL https://juejin.im/post/5bb23cc15188255c5121d499 Thank you so much

The project runs under Linux without any problems. When it is transported to a Windows machine, there is a problem of Chinese garbled characters, because it needs to connect to SSH to query some data, and the program will crash when encountering Chinese garbled codes.

At first I thought it was a problem with the encoding of the java file. Later I thought it was a problem with the encoding of the result of the ssh query. It took a few days to find out that the Chinese character in the Tomcat console under Windows was always garbled. Finally, the problem was solved through the above URL.

The only real step is to modify the registry: when Tomcat is started using startup.bat, it will read the code of catalina.bat and start a new window to run, but the default encoding of cmd opened by Tomcat is not utf-8, which leads to Garbled.

Solution:

Console part: Open the registry, press the path HKEY_CURRENT_USER→Console→Tomcat (Generally, the decompressed version of Tomcat will not have Tomcat in the console directory, so you need to create it manually), find the CodePage entry, and create it if you don’t have it (note the created When DWORD 32 bits are required), the setting value is 65001 in decimal.

Or copy the following code directly, save it as a .bat file with any name, and run it directly.

set rr="HKCU\Console\Tomcat"
reg add %rr% /v "CodePage" /t REG_DWORD /d 0x0000fde9 /f>nu

It is recommended to use the .bat file method here, which is relatively simple.

After completing the above operations, re-run startup.bat, right-click on the title bar of the newly pop-up cmd window, and click Properties, the display is as follows.
Insert picture description here
If the current code page is displayed as 65001, the modification is successful.

Guess you like

Origin blog.csdn.net/qq_32115939/article/details/103142253