Announcement Announcement Module
Collapse
No announcement yet.
Serious encoding problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Serious encoding problem

    Hi,

    I have problem with stringHttpMessageConverter character encoding. For example if the browser send a request (GET) while denoting the http accept header :
    Code:
    Accept: text/plain
    the response will be coded badly. For example, the french accent will be displayed on the browser as "?"

    I have UTF-8 everywhere in my configuration. Here is the request I use to reproduce the problem:

    Code:
    reda@spectrum:~$ curl -v -X GET -H"Accept: text/plain"  http://www.my-site.fr:8084/service/contacts-menu-content/r/r
    and here is the server side code:
    Code:
     @RequestMapping(value="/contacts-menu-content/{login}/{passwd}")
    	public @ResponseBody String simple(@PathVariable String login, @PathVariable String passwd, @RequestHeader("Accept") String accept) {
        	
        	return "bérénice";
    	}
    I have also configured my stringHttpMessageConverter as :

    Code:
     <bean id="inboundMessageAdapter" class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
            <property name="messageConverters">
            	
                <list>
                     <bean class="org.springframework.http.converter.StringHttpMessageConverter">
                     	<property name="supportedMediaTypes" value="text/plain"></property>
                     </bean>
                </list>
            </property>
        </bean>
    My web.xml has CharacterEncodingFilter set to UTF-8 on every request (/*)

    If I remove the Accept: text/plain , the accent are displayed well, but StringHttpMessageConverter is escaping all inverted comma (") with a backslash \ and I don't want that (There is no property to avoid this behavior)


    Anyone please can help me?
    Last edited by redsonic; Nov 27th, 2010, 02:28 AM.
Working...
X