-
Apr 7th, 2013, 05:15 PM
#1
Spring MVC Jabx2 ResponseBody with generic List
Hi there,
I'm very pleased by the possibilities given by Spring MVC in term of RESTFul capabilities, but I missed something talking about ResponseBody conversion.
Why can't we deal with List<?> the same way with JSON or XML conversion.
For instance, the Jackson converter will happily transform a list of Person (with a name field) in :
[{name: 'person1'}, {name: 'person2'}]
But the Jaxb converter will not be able to convert this List because List don't provide the @XmlRootElement. So I need to explicitly wrap my list in a wrapper object. From my point of view, this break the contract between Controller and View (rendering), because the Controller dedicate the return type for a specific ContentType acceptance.
I read something quite interesting here http://blog.bdoughan.com/2012/11/cre...r-in-jaxb.html
Maybe the Jaxb2RootElementHttpMessageConverter could be modified in order to provide such a fallback on generic type. Does it make sense ?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules