Garbled problems encountered in web development

Source: Internet
Author: User

I believe that everyone in the web development will encounter garbled problems, there are page garbled, request garbled, database garbled, and so on, here I enumerate the different cases of garbled solution:

1. The corresponding data garbled:

Just write the phrase in the background interface method to specify that the response character set is Utf-8
Response.setcontenttype ("Text/html;charset=utf-8");

2. Request data garbled:

①.get Request:

The first way the Tomcat default character set is Iso8859-1, you can manually convert it to the desired character set, manually transcoding;

The second way, configure the filter, use filter;

Third Way, directly modify the Tomcat configuration

<port= "8080"  protocol= "http/1.1"               connectiontimeout  = "20000"               redirectport= "8443"  uriecoding= "UTF-8" />

②post Request:

Request.setcharacterencoding ("Utf-8")

3. Database garbled:

Jdbc:useunicode=true&characterencoding=utf-8 create table  xxx () engine  Default Charset=utf-8

4.html file

<charset= "Utf-8">

5. Project code set to Utf-8

  

Garbled problems encountered in web development

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.