When I return a single object from a controller like this,
@ResponseBody
public MyClass module(...) {
...
}
I get the xml output on the client and log shows like this,
2011-09-07 18:22:06,963 [qtp1409490836-27] DEBUG org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter - Written [com.domain.MyClass@4374820d] as "application/xhtml+xml" using [org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter@b4e1f3]
But If I use a list like this,
@ResponseBody
public List<MyClass> module(...) {
...
}
It uses jsonConvertor and returns the json output.
2011-09-07 18:38:31,026 [qtp420370595-26] DEBUG org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter - Written [[com.domain.MyClass@654309f0]] as "application/json;charset=UTF-8" using [org.springframework.http.converter.json.MappingJacksonHttpMessageConverter@14419f80]
The MyClass is annotated with jaxb. In jersey I could say
@Produces({ MediaType.APPLICATION_XML })
How do I force spring to use the xmlconverter always?