The URL parameter in tomcat is Chinese. garbled characters are displayed after the servlet receives the request.

Source: Internet
Author: User

The URL parameter in tomcat is Chinese. garbled characters are displayed after the servlet receives the request.

When the parameter value in the URL is a text, the received servlet displays garbled characters, such:

 

Modify the server. xml file in tomcat. The file path is the conf folder under the tomcat installation directory. Is the server. xml file before modification.

 

The modified server. xml file. Added a line: URIEncoding = "UTF-8"

 

 

 

Restart the tomcat server after modification, and then test the operation.

 

Use request. setCharacterEncoding ("UTF-8"); To set the encoding format for Tomcat to receive requests,

 

Only valid for data submitted in POST mode and invalid for data submitted in GET mode!

 

To set the GET encoding, you can modify the server. in the xml file, the Connector attribute of the corresponding port: URIEncoding = "UTF-8", so that the data submitted in GET mode will be decoded correctly.

 

 

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.