Ajax submission Java background receive parameter garbled

Source: Internet
Author: User

1. Phenomenon:

Front Desk Ajax Submit query data

  $.ajax ({              ' bdmap/xx.action ',                Data:para,              dataType:' json ',              contentType :"application/x-www-form-urlencoded",              function(data) {                  if  (data.success) {                                           callback (data.data);        }})
    1. Request URL:http://localhost:8083/bdmap/xx.action?name=%E9%80%9F%E5%BA%A6
    2. Request Method: GET

Workaround: This Ajax commit, which is submitted by default in the Get method, is encoded by default using the UTF8 encoding format before committing, and then the Tomcat application Server decodes the URL, which is decoded by default using the Iso-8859-1 format, if a Chinese character is present in the URL, Encoding and decoding format should not be garbled.

Workaround One: Modify the format of the URL decoding in the Tomcat configuration file Server.xml, and set the uriencoding= "UTF-8" for the connector label, there are two needs to be modified.

<connector port= "8083" protocol= "http/1.1" connectiontimeout= "20000" redirectport= "8443" URIEncoding= "UTF- 8 "/>

<connector port= "8039" protocol= "ajp/1.3" redirectport= "8443" uriencoding= "UTF-8"/>

Workaround two: The front end uses the POST method to submit data, Ajax uses type: ' POST '.

Ajax submission Java background receive parameter 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.