As shown below JaxB provides for children to be differentiated by the tag name.
@XmlElements({
@XmlElement(name="horse", type=Horse.class),
@XmlElement(name="cow", type=Cow.class)
})
private Animal animal;
But how can I implement the desired functionality by default. Every Animal within the document should have the choice of Horse or Cow but I don't want to type the @XmlElements every time ?
It seems the solution is @XmlSeeAlso
http://docs.oracle.com/javaee/6/api/javax/xml/bind/annotation/XmlSeeAlso.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.