Java: Jersey (JAX-RS) and JAXB_FORMATTED_OUTPUT with annotation?

I currently have a Jersey web service (JAX-RS) that returns an annotated JAXB object with a simple @Produces("text/xml") in my Webservice method. Unfortunately, the result looks pretty dirty because it is not formatted with gaps and spaces.

Is there any annotation I can use, e.g. RESTeasy @Formatted

or

How to implement a marshaller and where?

+4
source share
2 answers

In Jersey, you can add the init parameter to your servlet:

 <init-param> <param-name>com.sun.jersey.config.feature.Formatted</param-name> <param-value>true</param-value> </init-param> 
+4
source

There is probably such an annotation in Jersey, but if you cannot use the JAX-RS MessageBodyWriter concept and directly use the JAXB Marshaller . Below is a link to the answer I gave, where MessageBodyReader was used to set the schema check on JAXB Unmarshaller :

0
source

All Articles