GRAILS 2.0上的格式编码问题 [英] Form Encoding Problems on GRAILS 2.0
问题描述
Content-Type:text / html; charset = utf-8
,而元标记同意。浏览器识别的页面为UTF-8,并正确显示字符。 发布表单时,浏览器将其编码为UTF-8。但是,当通过 params.paramname
读取数据时,数据看起来是乱码; maçã
成为maçã
。
检查,似乎是发送UTF-8数据的形式,但Grails似乎尝试阅读,就像是ISO-8859-1。在表单上设置 accept-charset =ISO-8859-1
确认此问题,因为它可以解决问题。
我也在applicationContext.xml上有:
< bean id =characterEncodingFilterclass =org.springframework.web.filter.CharacterEncodingFilter>
< property name =encoding>
< value> utf-8< / value>
< / property>
< property name =forceEncoding>
< value> true< / value>
< / property>
< / bean>
除了在应用程序中的所有表单中添加 accept-charset =ISO-8859-1
是否有解决方案?
谢谢。
我认为你遇到的问题与 Tomcat中的请求参数编码问题 - Burt的回答或意见对此有帮助。
I have an Grails application that is configured everywhere to function as UTF-8. While running a debug version, headers say Content-Type:text/html;charset=utf-8
, and meta tags agree. Browser identified page as UTF-8 and shows characters correctly.
When posting a form, the browser correctly sends it encoded as UTF-8. When reading the data via params.paramname
, however, the data looks garbled; maçã
becomes maçã
.
Upon further inspection, it seems the form is sending UTF-8 data, but Grails seem to try and read it as if it was ISO-8859-1. Setting accept-charset="ISO-8859-1"
on the form confirms this problem, as it fixes the problem.
I also have this on applicationContext.xml:
<bean id="characterEncodingFilter" class="org.springframework.web.filter.CharacterEncodingFilter">
<property name="encoding">
<value>utf-8</value>
</property>
<property name="forceEncoding">
<value>true</value>
</property>
</bean>
Is there an solution for this besides adding accept-charset="ISO-8859-1"
to all forms in the application?
Thanks.
I think you encounter the same problem as in Grails request parameters encoding issue in Tomcat - either Burt's answer or comments to it should help.
这篇关于GRAILS 2.0上的格式编码问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!