我正在使用marshaller生成XML
JAXBContext context = JAXBContext.newInstance(List.class);
Marshaller m = context.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
m.setProperty("com.sun.xml.bind.xmlDeclaration", Boolean.FALSE);
m.marshal(OrderList, stream);
StringWriter sw = new StringWriter();
m.marshal(OrderList, sw);
String val = sw.toString();
System.out.println(val);
在生成XML时,我将换行符Unicode字符 在XML节点中,值的开头和结尾。
例如<xyz> SomeText </xyz>
预期结果:
<xyz>
SomeText
</xyz>
但是输出如下:<xyz>SomeText</xyz>