Form Encoding Problems on GRAILS 2.0
- by ArmlessJohn
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.