How to get formatted xml output from jaxb in spring?

后端 未结 6 2253
陌清茗
陌清茗 2020-12-29 20:38

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?



        
6条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-12-29 21:07

    Try setting this property on your marshaller object:

     marshaller.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE )
    

    Here is the full Javadoc for the Marshaller interface. Check out the Field Summary section.

提交回复
热议问题