Unable to Override the Spring MVC URL decoding which uses default "ISO-8859-1"
We are passing "reifengr��e" which has 2 special German characters in the URL query string value. The request is received from the browser correctly encoded as "reifengr%C3%B6%C3%9Fe". But then the Spring MVC framework decodes it using default "ISO-8859-1" which results in "reifengrö�Ÿe" (wrong value).
We tried overriding this behavior by defining a filter that sets UTF-8 as the encoding
in the request but it does not work (even though the filter gets called before the Dispatcher Servlet). Also, tried adding below lines in the web.xml ...
*********************************************
<filter>
<filter-name>encoding-filter</filter-name>
<filter-class>
org.springframework.web.filter.CharacterEncodingFi lter
</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encoding-filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
*********************************************
before the dispatcher servlet but it did not work. We are using spring 3.0.0.RELEASE jars.
Is there a bug in the MVC framework ? What am I missing here ? Do I need to do anything additional ? Any help in this regard will be appreciated ?
Thanks.
Issue resolved -- Thanks.
Thanks a lot to both of you for your respective feedback on this issue. I do need the filter because the Request Body Content does need to be encoded / decoded using UTF-8. Thanks for clarifying on the point that this filter has no affect on the URI / URL itself but only on the Request Body. So I did make some configuration change in the server.xml of my Tomcat as recommended in "http://wiki.apache.org/tomcat/FAQ/CharacterEncoding#Q2" and then it started behaving as expected i.e UTF-8 decoded. I used the 2nd recommended option which says "Set the useBodyEncodingForURI attribute on the <Connector> element in server.xml to true. This will cause the Connector to use the request body's encoding for GET parameters. " since the latter is already taken care of with the filter I am using.
Thanks dlmiles & Julian Reschke for your help on this topic.