80,351
社区成员
发帖
与我相关
我的任务
分享
public String serializeForObject( Class<?> cls,Object object) throws Exception {
String xmlString="";
JAXBContext jaxbContext=JAXBContext.newInstance(cls);
Marshaller marshaller= jaxbContext.createMarshaller();
StringWriter stringWriter=new StringWriter();
marshaller.marshal(object, stringWriter);
//marshaller.marshal(object, stringWriter);
xmlString= stringWriter.toString();
return xmlString;
}
marshaller.marshal(object, stringWriter);
这一句下划了红色的波浪线