Java Chinese garbled problem solving

Source: Internet
Author: User
Tags tomcat server

1 Handling garbled mode:

1 when connecting to the database

2 Modifying the MySQL configuration file my.ini/my.cnf Default-character-set=utf8

3 Modify the configuration file in Tomcat Server.xml instead

<connector port= "8080" protocol= "http/1.1"

connectiontimeout= "20000"

Redirectport= "8443" uriencoding= "UTF-8"/>

4 Configuring the Spring filter in Web. xml













5 setting up the MySQL character set

Show variables like ' character_set_% ';

The displayed character_set_** are all set to UTF8, that is: Set character_set_serve= ' UTF8 '

Show variables like '%collation% ';

Set the display to be as follows: Set collation_server= ' Utf8_general_ci '

6. The Chinese characters in the HTTP (POST) request when the value is taken

In the servlet page, add

Request.setcharacterencoding ("Utf-8");

user_name = Request.getparameter ("user_name") = = null? "": (Request.getparameter ("user_name"), "UTF-8");

7. Front desk back????

Background assignment: errormessage = Urlencoder.encode ("No periodic data information in Redis", "UTF-8"). Replace ("+", "%20");

Front desk value: decodeURIComponent (errormessage)

Java Chinese garbled problem solving

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: 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.