2013-06-05 108 views
1

阅读下面的博客后,我编组了一个对象。 missing XMLRootunmarshall without XmlRoot

T objectToSerialize; 
JAXBElement<T> je=new JAXBElement<T>(new QName(“namespace”,”RootName”), T.class,objectToSerialize); 
marshaller.marshall(je,writer); 

现在我想解组以来,我整理类没有XmlRoot注解。我怎样才能解除这个?

回答

0

您需要使用采用Class参数的解组方法之一。

JAXBElement<Foo> je = unmarshaller.unmarshal(source, Foo.class); 
Foo foo = je.getValue();