<! -- 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