Solve tomcat's Chinese problem

  • 2020-05-13 04:09:10
  • OfStack

The Chinese problem with tomcat is that the character set cannot directly support double-byte information such as Chinese. One solution is to simply modify its configuration file as follows

Add a property called URIEncoding to the Server.xml file that encodes URL from the get method in the HTTP request. The following describes how to modify the server.xml file in the config folder in the Tomcat installation directory.

Open the config/ server.xml file. If you have not modified this file, you should find the following code:


<Connector port="8080" protocol="HTTP/1.1"
  connectionTimeout="20000"
  redirectPort="8443" />

This code specifies that Tomcat listens for the port number of the HTTP request and so on. You can add a property here: URIEncoding. By setting this property value to UTF-8, Tomcat will no longer process the get request in the encoding of ISO-8859-1. The changed code looks like this (the red part is the newly added code) :


<Connector port="8080"
 URIEncoding="utf-8"
  protocol="HTTP/1.1"
 connectionTimeout="20000"
  redirectPort="8443" />

After this modification, restart Tomcat and the test was successful.

That's all for this article, I hope you enjoy it.

Please take a moment to share this article with your friends or leave a comment. We will sincerely appreciate your support!


Related articles: