I am using Jaxb2Marshaller as a view property for ContentNegotiatingViewResolver. I am able to get the xml repsonse. How do I format (pretty print) it?
<bean
class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
<property name="mediaTypes">
<map>
<entry key="xml" value="application/xml" />
</map>
</property>
<property name="defaultViews">
<list>
<bean class="org.springframework.web.servlet.view.xml.MarshallingView">
<constructor-arg>
<bean class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="classesToBeBound">
<list>
</list>
</property>
</bean>
</constructor-arg>
</bean>
</list>
</property>
</bean>
Was looking for this and thought I'd share the code equivalent
Try setting this property on your marshaller object:
Here is the full Javadoc for the Marshaller interface. Check out the Field Summary section.
Ritesh's answer didn't work for me. I had to do the following:
Use jaxb.formatted.output instead of javax.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT as