Spring 3.0 making JSON response using jackson message converter
        Posted  
        
            by dupdup
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by dupdup
        
        
        
        Published on 2010-02-13T23:33:36Z
        Indexed on 
            2010/04/05
            9:23 UTC
        
        
        Read the original article
        Hit count: 1375
        
i configure my messageconverter as Jackson's then
class Foo{int x; int y}
and in controller
@ResponseBody
public Foo method(){
   return new Foo(3,4)
}
from that i m expecting to return a JSON string {x:'3',y:'4'} from server without any other configuration. but getting 404 error response to my ajax request
If the method is annotated with @ResponseBody, the return type is written to the response HTTP body. The return value will be converted to the declared method argument type using HttpMessageConverters.
Am I wrong ? or should I convert my response Object to Json string myself using serializer and then returning that string as response.(I could make string responses correctly) or should I make some other configurations ? like adding annotations for class Foo
here is my conf.xml
<bean id="jacksonMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
  <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
  <list>
    <ref bean="jacksonMessageConverter"/>
  </list>
</property>
© Stack Overflow or respective owner