gpt4 book ai didi

java - JAXB 和包含泛型的集合

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:23:21 25 4
gpt4 key购买 nike

我们有下面的 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com