我有 Booking.java
@XmlRootElement(name="booking")
@XmlAccessorType(XmlAccessType.FIELD)
class Booking{
@XmlElement(name="name", required = true, nillable = true)
private String name;
@XmlElement(name="contact",required = true, nillable = true)
private int contact;
@XmlElement(name="startDate", required = true, nillable = true)
private Date startDate;
@XmlElement(name="endDate", required = true, nillable = true)
private Date endDate;
@XmlElement(name="address", required = true, nillable = true)
private String address;
}
我正在使用 JAXB 进行编组,显示的输出如下
<booking>
<name>RAHUL</name>
<contact>9898989898</contact>
<startDate>2013-08-12T00:00:00+05:30</startDate>
<endDate>2013-01-12T00:00:00+05:30</endDate>
<address>Mumbai</address>
</booking>
但我希望输出如下
<booking>
<PersonalDetails>
<name>RAHUL</name>
<contact>9898989898</contact>
</PersonalDetails>
<startDate>2013-08-12T00:00:00+05:30</startDate>
<endDate>2013-01-12T00:00:00+05:30</endDate>
<address>Mumbai</address>
</booking>
我检查了 XMLElementWrapper,但它适用于 Collection。注意:我无法更改我的 pojo Booking.java