我有一個List<String>
,我想要序列化使用JAXB
。該名單也被一些XmlJavaTypeAdapter
預處理如下:如何使用JAXB和XmlJavaTypeAdapter序列化List?
@XmlElement(name = "category")
@XmlJavaTypeAdapter(AdapterXml.class) //for modifying some values inside the list during serialization
private List<String> categories;
結果:
Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
java.util.List is an interface, and JAXB cannot process interfaces.
this problem is related to the following location:
at java.util.List
爲什麼?我如何序列化列表?
我確實需要'XmlJavaTypeAdapter'來轉換列表中的值(爲列表中的每個字符串添加後綴和後綴)。所以我*不能*刪除它! – membersound