XmlTransient annotation yog dab tsi?
XmlTransient annotation yog dab tsi?

Video: XmlTransient annotation yog dab tsi?

Video: XmlTransient annotation yog dab tsi?
Video: Convert Java Object To XML Using JAXB 2024, Kaum ib hlis
Anonim

Cov lus piav qhia Hom XmlTransient . Cov @ XmlTransient annotation yog qhov muaj txiaj ntsig zoo rau kev daws cov npe sib tsoo ntawm JavaBean cov cuab yeej lub npe thiab lub npe teb lossis tiv thaiv daim phiaj xwm ntawm thaj chaw / khoom. Lub npe kev sib tsoo tuaj yeem tshwm sim thaum lub decapitalized JavaBean cov cuab yeej lub npe thiab lub npe teb yog tib yam.

Tsis tas li, kev siv @XmlRootElement annotation yog dab tsi?

@ XmlRootElement yog ib lus piav qhia uas neeg yog siv siv nrog JAXB (JSR-222). Nws yog lub hom phiaj yog kom tsis txhob koom nrog lub hauv paus ntsiab lus nrog ib chav kawm. Txij li cov chav kawm JAXB daim ntawv qhia rau cov hom nyuaj, nws muaj peev xwm ua tau rau ib chav kawm kom sib haum rau ntau lub hauv paus ntsiab lus.

Ib sab saum toj no, @XmlType yog dab tsi? Cov @ XmlType annotation tuaj yeem txhais tau rau hauv chav kawm. Cov ntsiab lus annotation propOrder() hauv @ XmlType annotation tso cai rau koj los qhia meej cov ntsiab lus txiav txim hauv hom schema generated. Hauv cov xwm txheej zoo li no, cov lus piav qhia @XmlAccessorOrder ua haujlwm ua ntej. Thaum cov ntsiab lus hauv chav kawm tau teev tseg los ntawm @ XmlType.

Cov lus nug tseem yog, kev siv @XmlElement yog dab tsi?

Hom lus piav qhia XmlElement . Maps a JavaBean cov cuab yeej rau a XML element muab los ntawm lub npe khoom. @ XmlElement annotation tuaj yeem yog siv nrog rau cov txheej txheem hauv qab no: JavaBean cov cuab yeej.

Jaxb puas tuaj yeem siv rau JSON?

JAXB JSON Piv txwv. JAXB yog java architecture rau XML khi yog ib qho cuab yeej siv tau zoo los hloov XML rau thiab los ntawm Java Object. EclipseLink JAXB (MOXy) yog ib qho ntawm JAXB kev siv uas feem ntau yog siv los tsim java chav kawm los ntawm XML los yog JSON.

Pom zoo: