JAXB.marshal() 如何去除 XML 头部
可以使用'Marshaller.JAXB_FRAGMENT'属性来控制是否输出XML头部。将该属性设置为'true',则不会输出XML头部,示例如下:
JAXBContext context = JAXBContext.newInstance(MyClass.class);
Marshaller marshaller = context.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
marshaller.marshal(myObject, System.out);
原文地址: http://www.cveoy.top/t/topic/mLJb 著作权归作者所有。请勿转载和采集!