Form form Submission Chinese garbled (foreground Chinese to Java background garbled) problems and solutions

Source: Internet
Author: User

Form form submitted in Chinese garbled (foreground Chinese to Java background garbled) problem and solve a problem:

The Chinese content in the page input box is garbled in the background, which causes the search function to fail; (see reproduced in detail later)

Second, Reason:

The browser's default encoding format for data is UTF-8, but Tomcat (TOMCAT7 and below) defaults to iso-8859-1 decoding, resulting in garbled characters;

Third, the solution:

3.1 Re-structuring the parameter string in the background;

Code one: activityname = new String (activityname.getbytes ("iso-8859-1"), "Utf-8");  One line of code can code two: Activityname = Java.net.URLEncoder.encode (Activityname, "iso-8859-1"); activityname = Java.net.URLDecoder.decode (Activityname, "UTF-8");

3.2 Directly change the Tomcat configuration

3.3 Many other ways to Baidu

Iv. Reproduction and resolution:

V. References:
    1. Chinese garbled in Java Urlencoder.encode method to call two resolution-CSDN blog http://blog.csdn.net/kongqz/article/details/9028111 (I just look at this solution)
    2. Post in Java, Chinese encoding & decoding issues-Dream it POSSIBLE-CSDN blog http://blog.csdn.net/hu_zhiting/article/details/52088245 (The tutorials are well written and there are many workarounds)
    3. Request and Response Setcharacterencoding () method-Kong_lev's blog-csdn blog http://blog.csdn.net/kong_lev/article/details/ 73071198 (Dapper)
    4. URL request in Chinese garbled processing-csdn blog http://blog.csdn.net/zhengyang7754/article/details/47263599 (Very long ... But did not read it)
<wiz_tmp_tag id= "Wiz-table-range-border" contenteditable= "false" style= "Display:none;" >

Form form Submission Chinese garbled (foreground Chinese to Java background garbled) problems and solutions

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.