[英]JaxB : Define default @XmlElements for a specific data type
As shown below JaxB provides for children to be differentiated by the tag name. 如下所示,JaxB允许通过标签名称区分孩子。
@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 ?
文档中的每个动物都应该选择“马”还是“牛”,但是我不想每次都键入@XmlElements吗?
It seems the solution is @XmlSeeAlso
看来解决方法是
@XmlSeeAlso
http://docs.oracle.com/javaee/6/api/javax/xml/bind/annotation/XmlSeeAlso.html http://docs.oracle.com/javaee/6/api/javax/xml/bind/annotation/XmlSeeAlso.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.