我正在对 java 对象进行 xml 解析,但解析时间正在获取billingDetails和expiryDetails *null* 我的 xml 是 _
<?xml version="1.0" encoding="UTF-8" standalone="yes">
<item>
<id>7</id>
<category>NONE</category>
<name>ServiceCharge</name>
<description>Service Charge</description>
<unitKey>NONE</unitKey>
<billingDetails>
<billFrequency>NONE</billFrequency>
<billingCycle>NOT_DEFINED</billingCycle>
</billingDetails>
<expiryDetails>
<expiryDays>0</expiryDays>
<expiryMethod>EXPIRE_PERIOD</expiryMethod>
</expiryDetails>
<gracePeriod>0</gracePeriod>
</item>
我在做这个java代码_
public static void digestItemsDetails(Digester digester, String root) {
String itemTag = root;
digester.addObjectCreate(itemTag, Item.class);
digester.addCallMethod(itemTag +"/id", "setId", 0);
digester.addCallMethod(itemTag +"/category", "setCategory", 0);
digester.addCallMethod(itemTag +"/name", "setName", 0);
digester.addCallMethod(itemTag +"/description", "setDescription", 0);
digester.addCallMethod(itemTag +"/unitKey", "setUnitKey", 0);
String billingPrefix = itemTag + "/billingDetails";
digester.addObjectCreate(billingPrefix, BillingDetails.class);
digester.addCallMethod(billingPrefix +"/billFrequency", "setBillFrequency", 0);
digester.addCallMethod(billingPrefix +"/billingCycle", "setBillingCycle", 0); 0);
String expiryPrefix = itemTag + "/expiryDetails";
digester.addObjectCreate(expiryPrefix, ExpiryDetails.class);
digester.addCallMethod(expiryPrefix +"/expiryDays", "setExpiryDays", 0);
digester.addCallMethod(expiryPrefix +"/expiryMethod", "setExpiryMethod", 0);
digester.addCallMethod(itemTag+"/gracePeriod", "setGracePeriod", 0);
}
Item.java类
public class Item {
....
public BillingDetails getBillingDetails() {
return billingDetails;
}
public void setBillingDetails(BillingDetails billingDetails) {
this.billingDetails = billingDetails;
}
......
}
但是我在billingDetails和expiryDetails中得到 NULL ,有没有朋友知道这有什么问题?谢谢