i’m looking for the simplest way of adding jaxb annotations support to jackson.
Jackson is added now to Spring by <mvc:annotation-driven/>. I need that by @ResponseBody annotation the Object is converted to xml or json dependently to the media type.
I’m new in spring-mvc so doesn’t understand well yet how things work. Thanks.
i’m looking for the simplest way of adding jaxb annotations support to jackson. Jackson
Share
Okay, I assume you want to be able to return both XML and JSON. To do this you need to create
MessageConverters for both formats.The XML message converter:
The JSON message converter, which uses the JAXB annotations:
And finally, the
AnnotationMethodHandlerAdapter, which will convert the responses to the appropriate content type, depending upon the accept headers:Note that the JAXB support in jackson isn’t 100% complete or correct all the time, but the developers are really good at fixing bugs and responding to error reports.