Currently I have my Jersey (JAX-RS) Webservice return an JAXB annotated Object with a simple @Produces("text/xml")
in my Webservice me开发者_Python百科thod. Unfortunately the output looks rather messy because its not formatted with breaks and spaces.
Is there an annotation I can use like RESTeasy's @Formatted
or
how do I implement a marshaller, and where?
In Jersey, you can add an init parameter to its servlet:
<init-param>
<param-name>com.sun.jersey.config.feature.Formatted</param-name>
<param-value>true</param-value>
</init-param>
There is probably such an annotation in Jersey, but if there isn't you could leverage the JAX-RS concept of a MessageBodyWriter
and leverage the JAXB Marshaller
directly. Below is a link to an answer I gave where a MessageBodyReader
was leveraged in order to set schema validation on a JAXB Unmarshaller
:
- Validate JAXBElement in JPA/JAX-RS Web Service
精彩评论