Using real POJOs (without JAXB Annotations) as transfer objects with JAX-RS

December 1st, 2011 · No Comments

Are you annoyed that you have to annotate your POJOs with @XmlRootElement, so they can be used with JAX-RS? If your using Jersey as JAX-RS implementation your lucky: Just add to the <servlet> tag in your web.xml the following snippet:

<init-param>
	<param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
	<param-value>true</param-value>
</init-param>

After restarting your servlet, your POJOs are marshalled to JSON as a charme. Enjoy!

Topics: · , , , , , , , , ,

0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.

Leave a Comment