2
我想使用參數從enum Type中創建一個xml。將Java ENUM轉換爲XML
如:
@XmlRootElement(name="category")
@XmlAccessorType(XmlAccessType.NONE)
public enum category{
FOOD(2, "egg"),
private final double value;
@XmlElement
private final String description;
private Category(double value, String name){
this.value = value;
this.description = name;
}
}
我想生成的XML是這樣
<category>
FOOD
<description>Egg</description>
</category>
,但是,這是我有:
<category>FOOD</category>
從javax.xml任何註解.bind.annotation可以做到這一點?
對不起,我英文不好
您是否嘗試過使用XmlAdapter? – SHiRKiT 2012-08-02 20:21:25