6
收集我有一個爲myBean註釋如何使用JAXB的馬歇爾/解組一的爲myBean
@XmlRootElement
public class MyBean ...
編組/解組爲myBean W/O問題,例如
JAXBContext jaxbCtx = JAXBContext.newInstance(MyBean.class);
Marshaller m = jaxbCtx.createMarshaller();
m.marshal(myBean, writer);
我該如何使用JAXB來編組/收集列表?
我嘗試導致此錯誤:
javax.xml.bind.MarshalException
- with linked exception:
[com.sun.istack.internal.SAXException2: unable to marshal type "java.util.ArrayList" as an element because it is missing an @XmlRootElement annotation]
at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:304)
at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:230)