Character garbled in URL parameter with Chinese

Source: Internet
Author: User

In the URL does not support the Chinese transmission, before the transmission needs the URI code, after the client code, transmits to the service side, needs to decode, the encoding and decoding format needs to unify.

Browsers and servers generally have a default encoding, which is automatically encoded and decoded when the Chinese is passed.

For example, the default encoding of the browser is UTF-8, the server-side default encoding is GB2312, when the parameters are passed to the service side, there is garbled.

In the Web development requires a uniform encoding, to avoid the problem of Chinese garbled.

The client can be encoded by JS, JS encoding format can only be utf-8, the server can set the default decoding format. add uriencoding= "UTF-8" to Server.xml when using the Tomcat container on the server

/apache-tomcat-7.0.61/conf/server.xml

<connector port= "8080" protocol= "http/1.1"
connectiontimeout= "20000"
Redirectport= "8443"
uriencoding= "UTF-8"/>

Reference article:

Front-end engineer code Skirmish http://ued.taobao.org/blog/2011/08/encode-war/

Character garbled in URL parameter with Chinese

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.