I am looking for a generic way of returning a set of objects in my REST service. I use the Spring3 message-converters and the @ResponseBody annotation.
Some sites say that JAXB2 has "problems" returning a standard java.util.List, and all examples found define a dedicated class (e.g. Authors, Products, Customers) for each data domain, such as:
http://www.ibm.com/developerworks/web/library/wa-spring3webserv/index.html (see "Collection of resources", second paragraph)
Has anyone found a way to provide a generic class/approach for this that spares me creating all those collection classes?
Update 5th April 2011: I haven't really made any progress on this. Returning a generic list object always results in a JAXBException "class XXX nor any of its super class is known to this context"
When creating REST services in a JAX-RS framework (which uses JAXB for XML binding) you can return a List. For an example see:
What happens when you try to do this with Spring?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With