When catalina.bat is set to UTF-8 in Tomcat, garbled characters appear on the console

When catalina.bat is set to UTF-8 in Tomcat, garbled characters appear on the console

1. The catalina.bat must be set to UTF-8. If I don't set it to UTF-8, the page receives garbled characters. I have tried various UTF-8 debugging methods, but to no avail. Finally, I can only set "JAVA_OPTS=%JAVA_OPTS% %JSSE_OPTS% -Dfile.encoding=UTF-8" in catalina.bat. Adding UTF-8 can solve the problem, but the command box and output log of tomcat are all garbled characters .


2. If you are using a compilation tool, you can solve the problem by setting -Dfile.encoding=UTF-8 in the VM options of the IDEA compiler, or by changing it to utf-8 in the eclipse settings. However, when deploying with Tomcat on a Windows server, the garbled characters cannot be solved.

3. Adding UTF-8 to service.xml is useless, and garbled characters are still displayed.

<Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8433" URIEncoding="UTF-8" />

<Connector port="8009" protocol="AJP/1.3" redirectPort="8433" URIEncoding="UTF-8"/>

Cause of the problem:

The default encoding set of Windows is GBK. When you use startup.bat to start Tomcat, it will read the code of catalina.bat and open a new window to run. The default encoding of the opened cmd may not be utf-8, which is inconsistent with the system encoding, resulting in garbled characters.


Solution:

Modify the encoding of the cmd command line, open the registry, find HKEY_CURRENT_USER→Console→Tomcat (if you changed the title bar of tomcat, this is the name of the command window you opened), find the CodePage item, create it if it does not exist, change the value to decimal 65001, and click OK.


This is the end of this article about the garbled characters appearing in the console when catalina.bat is set to UTF-8 in Tomcat. For more information about setting catalina.bat to UTF-8 in Tomcat, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Solve the problem of garbled characters in Tomcat console when starting IDEA
  • Tomcat garbled characters in the console in IDEA and how to set IDEA encoding to UTF-8
  • Solution to the garbled problem of SpringMVC Tomcat console
  • How to solve the problem of garbled Chinese characters in IDEA using Tomcat console
  • A debugging process record of Chinese garbled characters in the Tomcat source code startup console

<<:  Analysis and solution of flex layout collapse caused by Chrome 73

>>:  Detailed explanation of the usage of 5 different values ​​of CSS position

Recommend

Detailed analysis of Vue child components and parent components

Table of contents 1. Parent components and child ...

Four ways to create objects in JS

Table of contents 1. Create objects by literal va...

Windows 10 installation vmware14 tutorial diagram

Software Download Download software link: https:/...

Install and build a server environment of PHP+Apache+MySQL on CentOS

Yum (full name Yellow dog Updater, Modified) is a...

Example code for implementing a simple search engine with MySQL

Table of contents Preface Introduction ngram full...

Summary of some tips for bypassing nodejs code execution

Table of contents 1. child_process 2. Command exe...

How to center your HTML button

How to center your HTML button itself? This is ea...

jQuery achieves the effect of advertisement scrolling up and down

This article shares the specific code of jQuery t...

HTML Tutorial: title attribute and alt attribute

XHTML is the basis of CSS layout. jb51.net has al...

Problems with join queries and subqueries in MySQL

Table of contents Basic syntax for multi-table jo...

The difference between the four file extensions .html, .htm, .shtml and .shtm

Many friends who have just started to make web pag...