0
私はjaxbの使い方が新しく、XMLクラスの注釈を.xmlにマーシャリングできますが、アンマーシャリング中にデータを取得することはできません。非整列データでsysoutを実行すると、実際の値ではなくコンテキストのアドレスが出力されます。私はどこが間違っているのか分かりません。JAXBのアンマーシャリングの詳細
<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(); コレクションcollectionContext =(コレクション)jaxbUnmarshaller.unmarshal(new File( "TestXml.xml")); System.out.println(collectionContext); OUTPUT:[email protected] – yellow
オブジェクトを印刷しようとしているように見えます。そのオブジェクトのプロパティを印刷して、値だけを表示する必要があります。 System.out.println(customer.name); – spm