Results 1 to 2 of 2

Thread: utf8 handling in spring

  1. #1

    Default utf8 handling in spring

    Hi All,

    I am a bit puzzled about the utf8 handling in spring. As I have the following within my web.xml ...

    Code:
    	<filter>
    		<filter-name>encodingFilter</filter-name>
    		<filter-class>org.springframework.web.filter.CharacterEncodingFilter</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>encodingFilter</filter-name>
    		<url-pattern>/*</url-pattern>
    	</filter-mapping>
    ... I was under the impression that it would take care of all the utf8 business for me. Well, I was correct up to some extent... until I realised that the string parameters that I was reading in from the request url (within my controllers) were not being rendered properly !!

    So although non-english characters were treated fine in other parts of the application... when it came to...

    Code:
    String searchParameter = ServletRequestUtils.getStringParameter( request, "searchParam", "" )
    ... it messed up. I don't fully understand why.... haven't I already specified in my web.xml that it should all be treated as utf-8 ??

    Any pointers will be appreciated... thanks in advance.
    Last edited by ibnaziz; Mar 19th, 2009 at 01:32 AM.

  2. #2
    Join Date
    Oct 2005
    Location
    Amsterdam
    Posts
    123

    Default

    If you are using Tomcat, take a look at this: http://confluence.atlassian.com/disp...s+URI+encoding

    If not, you need to figure out how to do a similar thing for your servlet container
    Hans Westerbeek
    Software Engineer

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •