Garbled get and post Methods

Source: Internet
Author: User

①. Post method:

This method is relatively simple. You only need to add the code in the background as long as the format of the browser page encoding is used in the background:

 
Request. setcharacterencoding ("SHIFT-JIS"); // encoding format of the browser

②. Get method:

The parameter encoding after the URL is different from the encoding in the HTTP body. It is the default encoding format of the system (for example, the Japanese system isShift_jisThe request URL is encoded by Webserver, not servlet. Therefore, use "request. setcharacterencoding ("SHIFT-JIS"); "this code is invalid, so the solution is (take Tomcat as an example) to modify the Tomcat server. the XML file is as follows:

 1   <  Service  Name  = "Catalina"  > 2       <  Connector  Port  = "8080"  Protocol  = "Https/1.1"  3   Connectiontimeout  = "20000"  Uriencoding= "Shift_jis"  4   Redirectport  = "8443"  />  5   </  Service  > 

Add the following in the configuration file:Uriencoding = "shift_jis". In this way, the parameters after the URL will not be garbled.

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.