Lefteris Laskaridis
Lefteris Laskaridis

Reputation: 2322

Grails request parameters encoding issue in Tomcat

My grails app will not decode request parameters correctly.

In config.groovy:

All my gsp's use contentType="text/html; charset=UTF-8" on the page directive as well as <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> in the head element.

However, when i receive the posted parameters from the param object in my controller, the app just prints garbage...

I'm using Grails 1.3.7 version deployed over Tomcat 5. Other installed plugins except tomcat:

hibernate 1.3.7 jquery 1.7.1 spring-security-core 1.2.6 webxml 1.4

EDIT: From further debugging, i've noticed that the app will run fine in jetty. Therefore i suspect it must be a tomcat issue. My issue is similar to this post (alas i'm not using the Shiro plugin).

Can anyone help with this?

Upvotes: 5

Views: 4963

Answers (3)

Igors23m
Igors23m

Reputation: 1

As fas as no final conclusion made, I'd like to share my expierence in the same situation. Here one can find more discussion.

I my case, I have dev environment under the windows on local pc including local MySQL. Production env - Centos 6, MySQL, Tomcat 6 behind Apache.

In dev environment - everything was o'k, but on production - no. The only thing that help me - was set autoreconnect=true&useUnicode=true&characterEncoding=UTF-8 additionally to recommendations both for Tomcat URIEncoding='UTF-8'

So, the problem was in correct settings java Driver for MySQL.

Upvotes: 0

Viktor Nazarov
Viktor Nazarov

Reputation: 1

edit application.properties
add(update) line:
plugins.webxml=1.4.1

Upvotes: 0

Burt Beckwith
Burt Beckwith

Reputation: 75681

You need to add URIEncoding='UTF-8' to the Connector elements in conf/server.xml, e.g.

<Connector port='8080' protocol='HTTP/1.1' connectionTimeout='20000'
           redirectPort='8443' URIEncoding='UTF-8' />

This is described here: https://wiki.apache.org/tomcat/FAQ/CharacterEncoding

Upvotes: 9

Related Questions