<EXT2><![CDATA["不能"]]> </EXT2>
被转义成了
<EXT2><![CDATA["不能"]]></EXT2>
import org.springframework.web.util.HtmlUtils;
public String objToXml(Object obj) {
StringWriter sw = new StringWriter();
try {
JAXBContext jaxbContext = JAXBContext.newInstance(obj.getClass());
Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
marshaller.marshal(obj, sw);
} catch (JAXBException e) {
e.printStackTrace();
}
String xml = HtmlUtils.htmlUnescape(sw.toString());
return xml;
}
<EXT2><![CDATA["不能"]]></EXT2>