Solution to Chinese garbled characters in java

Source: Internet
Author: User

Solution 1:

When you pass the value to you, add a casual character to the back, and then use the substring to intercept the previous character. (Silly method)

 

Solution 2:

<Input type = "hidden" name = "" value = ""/> when passing a parameter in the shadow field on the page to the action, the passing value of this parameter does not seem to contain garbled characters.

 

Solution 3:

Configure Filter

 

Solution 4:

To transmit Chinese Characters in these two URLs, the url must be encoded and decoded.

Encoding: encodeURI ("string containing Chinese characters "))

Decoding: java.net. URLDecoder. decode ("the string to be decoded", "UTF-8 ");

 

Solution 5 (the most common solution ):

<Connector port = "8081" protocol = "HTTP/1.1"
ConnectionTimeout = "20000"
RedirectPort = "8443"
URLEncoding = "UTF-8"
/> Www.2cto.com

Server. xml configuration file in the tomcat conf folder

Add URLEncoding = "UTF-8"

You can implement unified character conversion to convert the default URL to unicode encoding.

Changed to UTF-8 encoding to solve the problem of Garbled text jump between Chinese pages.

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.