JAXB / Jersey - Feed没有显示我的嵌套列表 - 任何想法?

时间:2011-02-17 20:08:28

标签: java json jaxb jersey jax-rs

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

我希望JAXB / Jersey能够在Project的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;
    }
}

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

1 个答案:

答案 0 :(得分:0)

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