0
我是jaxb使用新手,我可以編組帶有xml註釋的java類到.xml,但無法在解組時收回數據。當我對我的非編組數據執行sysout時,它會打印上下文的地址而不是實際的值。我不確定我出錯的地方。JAXB unmarshalling詳細
<collections>
<collectionclass="testclass">
<group>
<header code="T123" type="toys"/>
<obj1 location="1" shelf="4" />
<obj2 location="7" shelf="2" count="3"/>
<associations>
<association type="String" associatedName="train" associatedFieldSize="0"/>
<association type="DataLength" associatedName="ship" associatedFieldSize="0"/>
</associations>
</obj2>
</group>
<collectionclass="testclass">
</collections>
此外,我想知道更多關於像解組XML文檔,它是如何進入照片而產生的「JAXB語境」和「Java模型/ Java模型類」條款。
在此先感謝!
我想是這樣的, 的JAXBContext JAXBContext而= JAXBContext.newInstance(Collections.class); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); Collections collectionContext =(Collections)jaxbUnmarshaller.unmarshal(new File(「TestXml.xml」)); System.out.println(collectionContext); 輸出:[email protected] – yellow
看起來您正在嘗試打印該對象。您應該在該對象中打印屬性,然後只能看到這些值。的System.out.println(customer.name); – spm