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