How to get formatted xml output from jaxb in spring?

后端 未结 6 2310
陌清茗
陌清茗 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:08

    Use jaxb.formatted.output instead of javax.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT as

    Map map = new HashMap();
    map.put("jaxb.formatted.output", true);
    jaxb2Marshaller.setMarshallerProperties(map);
    

提交回复
热议问题