如何在TAG中包含不同的标签,我需要保留订单:
<elements>
<field></field>
<field></field>
<tab></tab>
<field></field>
<tab></tab>
<listing></listing>
....
</elements>
有人认为像JSF树一样。
将ViewField和ViewTab作为ViewElement的派生类,我尝试:
@XmlRootElement
public class ViewTab extends ViewElement{
private List<ViewField> fields = new ArrayList<ViewField>();
public List<ViewField> getFields() {
return fields;
}
@XmlElementWrapper(name="elements")<--- try the same element wrapper
@XmlElement(name="field", nillable=true)
public void setFields(List<ViewField> fields) {
this.fields = fields;
}
private List<ViewTab> tabs = new ArrayList<ViewTab>();
public List<ViewTab> getTabs() {
return tabs;
}
@XmlElementWrapper(name="elements")
@XmlElement(name="tab", nillable=true)
public void setTabs(List<ViewTab> tabs) {
this.tabs = tabs;
}
}