我正在使用eBay的查找服务,除了解析unitPrice之外,一切正常。它说here:
eBay使用UnitType和UnitQuantity
所以在我的UnitPriceInfo.java中我有这个:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "UnitPriceInfo", propOrder = { "type", "quantity", "any" })
public class UnitPriceInfo
{
@XmlElement(name = "UnitType")
protected String type;
@XmlElement(name = "UnitQuantity")
protected Double quantity;
@XmlAnyElement(lax = true)
protected List<Object> any;
但是,UnitPriceInfo
对象仍然被实例化,但它们总是将类型和数量字段都归零。
我是否需要将字符串和Double的类型更改为UnitType
和UnitQuantity
?如果没有,问题是什么?
答案 0 :(得分:0)
元素名为type
和quantity
,如下所示:
<unitPrice>
<quantity> double </quantity>
<type> string </type>
</unitPrice>
您应将注释更改为@XmlElement(name="type")
和@XmlElement(name="quantity")
。
答案 1 :(得分:-1)
是否可以将类名从UnitPriceInfo更改为“unitPrice”或为类名提供带注释的名称“unitPrice”。