JAXB / Jersey - Feed 不显示我的嵌套列表 - 有什么想法吗?

发布于 2024-10-18 02:25:14 字数 1127 浏览 4 评论 0原文

这真的很令人沮丧,我已经和这个问题斗争了近 5 个小时了…:(

我希望 JAXB/Jersey 将我的下载列表嵌入到项目的 Json Feed 中…但不幸的是它完全丢失了。

这里是代码片段:

Project.java
...
@XmlElement
    public final List<Download> getDownloads() {
        return this.downloads;
    }
...

我可以毫无问题地获取下载对象本身...

{"contentType":"application/zip","fileName":"source_something.zip","key":"17","title":"Some new title"}

当我使用字符串列表时 - 一切都工作得很好!

@XmlElement
    public final List<String> getTechnologies() {
        return this.technologies;
    }

project.json 的输出(请参阅嵌套技术列表):

{"key":"16","date":"1999-01-13T02:23:31.712Z","description":"someDesc","teaser":"This is just a teaser!","technologies":["someTec1","someTec2","bar","foo"],"title":"My First Project","type":"MOBILE"}

我的下载类看起来非常像这样(正如我已经提到的 - 直接使用时效果很好):

@XmlRootElement
public class Download extends BaseDownloadBean {
...

@XmlElement
    public final String getFileName() {
        return this.filename;
    }
}

你们知道问题可能是什么吗?

it's really frustrating and I've been fighting with this issue for almost 5 hours now... :(

I'd expect JAXB/Jersey to embed my list of downloads in the Project's Json Feed... but unfortunately it's completely missing.

Here's the code snippet:

Project.java
...
@XmlElement
    public final List<Download> getDownloads() {
        return this.downloads;
    }
...

I can fetch the Download object itself without any problems...

{"contentType":"application/zip","fileName":"source_something.zip","key":"17","title":"Some new title"}

When I use a list of Strings - everything works perfectly fine!

@XmlElement
    public final List<String> getTechnologies() {
        return this.technologies;
    }

Output of project.json (see nested technologies list):

{"key":"16","date":"1999-01-13T02:23:31.712Z","description":"someDesc","teaser":"This is just a teaser!","technologies":["someTec1","someTec2","bar","foo"],"title":"My First Project","type":"MOBILE"}

My Download class looks pretty much like this (and as I've mentioned already - this works pretty fine when used directly):

@XmlRootElement
public class Download extends BaseDownloadBean {
...

@XmlElement
    public final String getFileName() {
        return this.filename;
    }
}

Do you guys have any idea what the problem might be?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

月下客 2024-10-25 02:25:14

Download 对象设置为 JAXB 带注释的类应该可以解决该问题。

Setting the Download object to be a JAXB annotated class should solve the problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文