我们有下面的 JAXB/Java 代码。在我们更改 List<JQGridTO> rows
之前,这一切都很好至 List<? extends JQGridTO> rows
.
当我们进行更改时,出现此错误:
Constructor threw exception; nested exception is com.sun. xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions Property rows appears in @XmlType.propOrder, but no such property exists. Maybe you meant records? this problem is related to the following location: at com.me.ui.service.JQGridJsonRoot
为什么会出现这个错误?您不能像我们一样使用泛型(即:指定 ? extends XXX
)吗?
@XmlRootElement
@XmlType(name = "", propOrder = {
"records",
"page",
"total",
"rows"
})
public class JQGridJsonRoot {
int total; //total pages for the query
int page; //current page of the query
int records; //total number of records for the query
List<? extends JQGridTO> rows
...
最佳答案
看看这篇 SO 帖子。我想它有你需要的:JAXB Marshalling and Generics
关于java - JAXB 和包含泛型的集合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4136240/