且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用JAXB进行解组

更新时间:2023-10-15 09:11:10

看来你可能已经注释了getPeople和setPeople方法。 JAXB(和其他Java EE技术)只需要您注释一个。

It appears that you may have annotated both the getPeople and setPeople methods. JAXB (and other Java EE technologies) only require you annotate one.

public class Community {

    private List<Person> people;

    @XmlElementRef
    public List<Person> getPeople() {
        return people;
    }

    public void setPeople(List<Person> people) {
        this.people = people;
    } 

}

更多信息

  • http://blog.bdoughan.com/2010/11/jaxb-and-inheritance-using-substitution.html
  • http://blog.bdoughan.com/2011/06/using-jaxbs-xmlaccessortype-to.html