我使用xjc创建了一些类。
public class MyType {
@XmlElementRefs({
@XmlElementRef(name = "MyInnerType", type = JAXBElement.class, required = false),
})
@XmlMixed
protected List<Serializable> content;
public List<Serializable> getContent() {
if (content == null) {
content = new ArrayList<Serializable>();
}
return this.content;
}
}
但是我无法使用
添加内部元素。getContent().add(newItem);
因为MyInnerType不可序列化。为什么它不是对象列表?我如何添加内部元素?