Solve Chinese garbled characters submitted by JSP

Source: Internet
Author: User

When a JSP parameter is passed today, Chinese characters are garbled and added on the page

Code:
  1. <% @ Page Language = "Java" contenttype = "text/html; charset = UTF-8"
  2. Pageencoding = "UTF-8" %>
  3. <% Request. setcharacterencoding ("UTF-8"); %>

The Chinese characters are displayed normally.

Recently, I changed some default encoding settings of myeclipse, which always produces Chinese garbled characters, causing my headache. I am going to study it.

------------------------------

Http://blog.163.com/luyufen_luise/blog/static/5777392520103132253440/

The above website shows a method to configure the filter. You only need to configure the Web. xml file to solve Chinese garbled characters on the page.

Open the Web. xml file under the WEB-INF directory and add the following:

Code:
  1. <Filter>
  2. <Filter-Name> encodingfilter </filter-Name>
  3. <Filter-class>
  4. Org. springframework. Web. Filter. characterencodingfilter
  5. </Filter-class>
  6. <Init-param>
  7. <Param-Name> encoding </param-Name>
  8. <Param-value> UTF-8 </param-value>
  9. </Init-param>
  10. </Filter>
  11. <Filter-mapping>
  12. <Filter-name> encodingFilter </filter-name>
  13. <Url-pattern>/* </url-pattern>
  14. </Filter-mapping>

The configuration in this section uses the filters in the jar package of spring to process Chinese garbled characters, which is convenient and practical. I hope to help the technical staff with relevant problems!

If you do not use the spring jar package, you need to write the filter yourself.

 

Related Articles:

Http://applelini.blog.163.com/blog/static/98652780201001425758226? Fromdm & fromsearch & isfromsearchengine = Yes

Http://chenmingming2000.blog.163.com/blog/static/2000687520094223110187? Fromdm & fromsearch & isfromsearchengine = Yes

Http://applelini.blog.163.com/blog/static/98652780201001425758226? Fromdm & fromsearch & isfromsearchengine = Yes

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.