本文介绍了Spring MVC中的UTF-8编码,FORMs的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在web.xml中有这个
< filter>
< filter-name> encoding-filter< / 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> encoding-filter< / filter-name>
< url-pattern> / *< / url-pattern>
< / filter-mapping>
并且在file.jsp的顶部,我有:
<%@ page pageEncoding =UTF-8contentType =text / html; charset = UTF-8%& code>< head>
这个: / p>
< meta http-equiv =Content-Typecontent =text / html; charset = UTF-8/> ;
和使用方法POST从FORM设置的latin-1以外的字符仍然不正确。
解决方案我解决了这个问题。
过滤文件。
I have this in web.xml
<filter> <filter-name>encoding-filter</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>encoding-filter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
and at the top of file.jsp I have this:
<%@ page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
in
<head>
this:<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
and characters other than latin-1 set from FORM with method POST are still not correct.
解决方案I solved this.
That filter in web.xml must be first filter in file.
这篇关于Spring MVC中的UTF-8编码,FORMs的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!