Tomcat is a web server widely used by Java developers. It is favored by Java Web programmers because of its low resource usage and fast running speed. However, in use, due to the existence of Chinese problems in Java, if not configured, the web program cannot directly support downloading files with Chinese file names, this makes Java Web Program Development inconvenient. This article describes a method to solve this problem.
The core of solving the problem is to modify tomcat configuration. In the server. xml file, add a property named uriencoding, which is used to encode the URL passed by the get method in the HTTP request. If you download Tomcat directly from the Apache site, whether it is the installation version of the EXE file, or extract the ZIP file, built-in for get protocol URL encoding is ISO-8859-1, this character set cannot directly support Chinese and other dubyte information, and the download link of Chinese files is exactly through the get protocol. 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 the file has not been modified, you can find the following code in it:
<Connector Port = "8080" protocol = "HTTP/1.1"
Connectiontimeout = "20000"
Redirectport = "8443" type = "regxph" text = "yourobjectname"/>
This Code specifies information such as the port number That tomcat listens to the HTTP request, you can add an attribute here: uriencoding, set this attribute value to the UTF-8, so that Tomcat no longer processes get requests in the ISO-8859-1 encoding. The changed code is as follows (the red part is the newly added code ):
<Connection Port = "8080"
Uriencoding = "UTF-8"
Protocol = "HTTP/1.1"
Connectiontimeout = "20000"
Redirectport = "8443" type = "regxph" text = "yourobjectname"/>