java对象转换String类型的XML格式
//输出
StringWriter sw = new StringWriter();
//转换类
JAXBContext context = JAXBContext.newInstance(obj.getClass());
Marshaller marshaller = context.createMarshaller();
// 格式化输出的格式
marshaller.setProperty(Marshaller.JAXB_FRAGNENT,true);//去掉xml默认生成的报文头
marshaller
原创
2021-04-12 17:00:47 ·
282 阅读 ·
0 评论