Character filter settings in Web. xml

Source: Internet
Author: User
<! -- Character encoding filter --> <filter-Name> encodingfilter </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> <init-param> <param-Name> forceencoding </param-Name> <param-value> true </param-value> </init-param> </Filter> <filter-mapping> <filter-Name> encodingfilter </filter-Name> <URL-pattern>/* </url-pattern> </filter-mapping>

Current JSP page and JavaCodeWhen different character sets are used for encoding, the data submitted by the form or the garbled characters of the uploaded/downloaded Chinese name file may occur, so this class can be used.

Encoding -----> specifies a specific character set.

Forceencoding -------> in earlier versions of spring, this parameter has a single role. When a character set has been specified in the request, whether or not to set the character set corresponding to endcoding to the request. For example, if the filter is configured to the Web as above. XML. when the request is submitted, the filter determines the request. whether getcharacterencoding () is null. If it is null, request will be made. setcharacterencoding ("UTF-8") operation, if not null then the filter will do nothing.

Reference: http://blog.csdn.net/heidan2006/article/details/3075730

Http://book.51cto.com/art/200909/153497.htm

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.