Form Encoding Problems on GRAILS 2.0
Posted
by
ArmlessJohn
on Stack Overflow
See other posts from Stack Overflow
or by ArmlessJohn
Published on 2012-06-01T19:49:03Z
Indexed on
2012/06/05
16:40 UTC
Read the original article
Hit count: 251
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.
© Stack Overflow or respective owner