tomcatgrailsgrails-pluginappfog

Grails 2.3 web-xml and Tomcat URIEncoding


I'm having Grails 2.3.11 application deployed to AppFog (tomcat 6 instance) and having problem with Tomcat's default URIEncoding set to ISO-8859-1 (croatian characters received through GET request are unusable). I found that, in my case, Connector settings within Tomcat's server.xml should be configured with URIEncoding="UTF-8" option (I tested it on docker image and it's working with this option). Since I'm not sure can I even configure this settings on Appfog, I'm wondering is there any way (and how) to do it through Grails web-xml plugin (conf/WebXmlConfig.groovy file?) (just to note that this is the only way to go, all other encodings for gsp, jsp, html and even file encodings are set to UTF-8)

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

    <bean id="grailsApplication" class="org.codehaus.groovy.grails.commons.GrailsApplicationFactoryBean">
        <description>Grails application factory bean</description>
        <property name="grailsDescriptor" value="/WEB-INF/grails.xml" />
        <!-- <property name="grailsResourceLoader" ref="grailsResourceLoader" /> -->
    </bean>

    <bean id="pluginManager" class="org.codehaus.groovy.grails.plugins.GrailsPluginManagerFactoryBean">
        <description>A bean that manages Grails plugins</description>
        <property name="grailsDescriptor" value="/WEB-INF/grails.xml" />
        <property name="application" ref="grailsApplication" />
    </bean>

    <bean id="grailsConfigurator" class="org.codehaus.groovy.grails.commons.spring.GrailsRuntimeConfigurator">
        <constructor-arg>
            <ref bean="grailsApplication" />
        </constructor-arg>
        <property name="pluginManager" ref="pluginManager" />
    </bean>

    <!-- 
    <bean id="grailsResourceLoader" class="org.codehaus.groovy.grails.commons.GrailsResourceLoaderFactoryBean" />
    -->

    <bean id="characterEncodingFilter" class="org.springframework.web.filter.CharacterEncodingFilter">
        <property name="encoding">
            <value>utf-8</value>
        </property>
    </bean>

    <bean id="conversionService" class="org.springframework.context.support.ConversionServiceFactoryBean" />
</beans>

Solution

  • There isn't a way to configure this at the web.xml level, that is why Grails has a characterEncodingFilter which sets the default encoding to utf-8: