我无法解组嵌套的复杂对象。在下面的xml例子中,“Racing”有一个RacingTicket对象。这可以通过rdf:about链接来实现,这是一个获得RacingTicket的宁静服务调用。
<?xml version='1.0' encoding='UTF-8'?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:hl="http://racing.com/horses/holding-location">
<title type="text">Create Racing Event</title>
<id>http://www.racing.com/</id>
<content type="application/xml">
<racing xmlns="http://racing.com/schema/horses">
<racingTicket rdf:about="https://racing.com/fast/racingTicket/asdf-asfd-asdf-asdf-asdf" />
<tracks>
<track>
<title>ABX</title>
<amount>560</amount>
</track>
</tracks>
<racingId>001</racingId>
</racing>
</content>
</entry>
Java class
@XmlRootElement
public class Racing implements Serializable {
@AtomId( prefixUrl = "http://racing.com/fast/racingTicket/" )
private String id;
private RacingTicket racingTicket;
private Tracks tracks;
private BigDecimal racingId;
public RacingTicket getRacingTicket() {
return racingTicket;
}
@XmlElement
public void setRacingTicket( RacingTicket racingTicket ) {
this.racingTicket = racingTicket;
}
jaxb unmarshaler返回的对象包含racingTicket类的所有值为null。 请指教,任何帮助表示赞赏。
答案 0 :(得分:0)