阅读下面的博客后,我整理了一个对象。 missing XMLRoot
T objectToSerialize;
JAXBElement<T> je=new JAXBElement<T>(new QName(“namespace”,”RootName”), T.class,objectToSerialize );
marshaller.marshall(je,writer);
现在我想对其进行解码,因为我编码的类没有 XmlRoot 注释。我该如何解码这个?
最佳答案
您需要使用采用 Class
参数的解码方法之一。
JAXBElement<Foo> je = unmarshaller.unmarshal(source, Foo.class);
Foo foo = je.getValue();
关于java - 不使用 XmlRoot 进行解码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16943257/