Solutions to Chinese garbled web pages-I have wings

Source: Internet
Author: User
Solution to Chinese garbled characters on webpages-I have wings 1. Solve Chinese problems on HTML pages: To make HTML pages support Chinese characters well, you must add the following code in the header of each HTML page:

...

...

2. Solve the Problem of Chinese Characters in JSP pages. To make JSP pages support Chinese characters well, add the following code in the header of each JSP page:

<% @ Page contentType = "text/html; charset = gb2312" language = "java" %>

3. Solve the Problem of Servlet response results in Chinese. To make the Servlet page support Chinese well, you must add the following code in the header of each Servlet page:

Response. setCharacterEncoding ("gb2312 ");

4. Solve the Chinese problem of page data transmission. In order to make Chinese data normally transmitted between pages (components), the best solution is to use the encoding filter. Configure an encoding filter in WEB. XML with the following content:


EncodingFilter
Org. springframework. web. filter. CharacterEncodingFilter

Encoding

Gb2312





EncodingFilter
/*

5. solve the Chinese problem in HTTP (get) Request: by default, IE browser sends a "ISO-8859-1" encoding format to send the request, if the HTTP get request Chinese parameters are garbled, you can encode and convert it, for example:

String param = request. getParameter ("param ");

Param = new String (param. getBytes ("ISO-8859-1", "GB2312 "));

You can also modify the Tomcat server. xml file to solve the problem:

...

URIEncoding = "GB2312"/> --> Add this

6. Solve the Chinese problem of MySQL database: Solve the Chinese problem of MySQL database mainly on the URL of the JDBC driver, for example:

Jdbc: mysql: // localhost/test? User = root & password = 123456 & useUnicode = true & characterEncoding = gb2312

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.