Tomcat supports download of Chinese file names

Source: Internet
Author: User
Tomcat is a web server widely used by Java developers. because of its low resource usage and high running speed, it is widely used by Java WebProgramMembers. 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, which is Java
The development of web programs is 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 in it:Code:

<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"/>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.