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