I have the following annotation using javax.xml.bind.annotation.XmlElement:
@XmlElement
public List getKeywords() {
r
Above answer by - Blaise Doughan is completely correct
Another simple way is , even if you don't write the - @XmlElementWrapper
private List keywords;
@XmlElementWrapper
@XmlElement(name="keyword")
public List getKeywords() {
return keywords;
}
You can use it this way - write the XmlAccessorType on Class level , then XML element name will be same as the class member name - keywords
import java.util.List;
import javax.xml.bind.annotation.*;
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Content {
private List keywords;
public Content() {}
public List getKeywords() {
return keywords;
}
public void setKeywords(List keywords) {
this.keywords = keywords;
}
}