java - How to marshall a set with jaxb? -


मेरे पास निम्न कोड है:

  @XmlRootElement (name = "foo") @ XmlAccessorType (XmlAccessType.FIELD) सार्वजनिक वर्ग फ़ू {@XmlElement निजी स्ट्रिंग आईडी; ...}  

मुझे एक सेट & lt; Foo & gt; मार्शल करने में सक्षम होना चाहते हैं। Foos में:

  & lt; foos & gt; & LT; foo & gt; & LT; आईडी & gt; bar1 & lt; / आईडी & gt; & Lt; / foo & gt; & LT; foo & gt; & LT; आईडी & gt; bar2 & lt; / आईडी & gt; & Lt; / foo & gt; & Lt; / कम महत्वपूर्ण चीज़ें & gt;  

क्या मुझे आवरण वर्ग की आवश्यकता है? यदि हां, तो इसे कैसे देखना चाहिए? क्या मेरी टिप्पणियां सही हैं? कैसे marhalling कोड की तरह दिखना चाहिए (यदि आप यह सब समझा सकता है, तो बहुत सराहना की जाएगी)?

"post-text" itemprop = "text"> < P> यदि आप किसी भी संग्रह उपयोग को समापित करना चाहते हैं

  @XmlElementWrapper (name = "foos") @XmlElement (name = "foo") निजी सेट & lt; Foo & gt; कम महत्वपूर्ण चीज़ें;  

जिस तरह से आप सीधे सेट एक सेट नहीं कर सकते हैं, इसलिए आपको अपने खुद के वर्ग के अंदर सेट करना शामिल करना होगा। इसलिए यदि आप फ़ू का एक सेट मार्शल करना चाहते हैं तो आपको इस तरह से बीन लिखना होगा:

  @ xmlrootelement (name = "foos") सार्वजनिक वर्ग फ़्यूज़ {@XmlElement (name = "foo ") निजी सेट & lt; Foo & gt; foo; }  

Comments

Popular posts from this blog

HTML/CSS - Automatically set height width from background image? -

php - Mysql Show Process - Sleep Commands and what to do -

c - What is the address of buf (the local variable in the main function)? -