Chinese garbled problem (page garbled, Eclipse garbled, request response garbled)

Source: Internet
Author: User

1. First set the workspace and file encoding format in the development tool eclipse, see http://www.cnblogs.com/lixiang1993/p/7345161.html

2. In the installation root of Eclipse, open the Eclipse.ini file and add "-dfile.encoding=utf-8" to the last line of the file so that the files created in eclipse are saved with Utf-8 encoding.

3, the request garbled problem

(1) solve the GET request garbled problem: In the Tomcat root directory, enter the Conf folder, open Server.xml file, search connector, add attribute uriencoding, attribute value is UTF-8,

Note: There are multiple connector in the file, note the selection.

  

(2) solve the problem of POST request garbled

① before receiving the parameter, encode it,

Request.setcharacterencoding ("Utf-8");

②SSM frame, add post garbled filter

<!--Post garbled filter -  <Filter>    <Filter-name>Characterencodingfilter</Filter-name>    <Filter-class>Org.springframework.web.filter.CharacterEncodingFilter</Filter-class>    <Init-param>        <Param-name>Encoding</Param-name>        <Param-value>Utf-8</Param-value>    </Init-param>  </Filter>  <filter-mapping>    <Filter-name>Characterencodingfilter</Filter-name>    <Url-pattern>/*</Url-pattern>  </filter-mapping>

4, Response garbled problem

Before passing the parameter, encode it,

Response.setcontenttype ("Text/html;charset=utf-8");

Chinese garbled problem (page garbled, Eclipse garbled, request response garbled)

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.