我有以下代码
@XmlAccessorType(XmlAccessType.NONE)
public class SeatDescriptor {
String id;
Seat seat;
@XmlAttribute
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
@XmlElement
public Seat getSeat() {
return seat;
}
public void setSeat(Seat seat) {
this.seat = seat;
}
}
@XmlAccessorType(XmlAccessType.NONE)
public class Seat {
int number;
@XmlAttribute
public int getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
}
}
代码生成以下类型的XML
<seatdesc id="ii">
<seat number="20"/>
</seatdesc>
我想要的是seatdesc
标签上的Seat对象的属性。我怎样才能做到这一点?
<seatdesc id="ii" number="20" />