Skip to content Skip to sidebar Skip to footer

Utf-8 Encoding With Form Post And Spring Controller

I am trying to submit a form, which has UTF8 characters inside it. The form looks like this:

Solution 2:

Do you have a filter-mapping entry in your web.xml for EncodingFilter?

<filter-mapping><filter-name>EncodingFilter</filter-name><url-pattern>*</url-pattern></filter-mapping>

Solution 3:

I would suggest you remove the CharacterEncodingFilter, which may itself be the cause of double encoding.

To debug the situtation, you should first check if the browser is posting the data correctly. Use Firebug (for Firefox) or developer tools on Chrome (F12)

Most likely, the problem is at the server side. Which server do you use? If you use Tomcat, you need to set the CharsetEncoding to UTF-8 on the Connector element in server.xml

Update 1:

It looks very likely that the problem is the forceEncoding that you are setting. As per the docs

This filter can either apply its encoding if the request does not already specify an encoding, or enforce this filter's encoding in any case ("forceEncoding"="true")

When you do a get, there is no encoding specified, so it makes sense that it works.

However when you do the POST, the encoding is already applied and then (it seems) is applied again because of the forceEncoding=true

Post a Comment for "Utf-8 Encoding With Form Post And Spring Controller"