JAXB / Jersey - Feed 不显示我的嵌套列表 - 有什么想法吗?
这真的很令人沮丧,我已经和这个问题斗争了近 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将
Download
对象设置为 JAXB 带注释的类应该可以解决该问题。Setting the
Download
object to be a JAXB annotated class should solve the problem.