I used @LiorH’s example and expanded it to:
@XmlRootElement(name="List")
public class JaxbList<T>{
protected List<T> list;
public JaxbList(){}
public JaxbList(List<T> list){
this.list=list;
}
@XmlElement(name="Item")
public List<T> getList(){
return list;
}
}
Note, that it uses generics so you can use it with other classes than String. Now, the application code is simply:
@GET
@Path("/test2")
public JaxbList test2(){
List list=new Vector();
list.add("a");
list.add("b");
return new JaxbList(list);
}
Why doesn’t this simple class exist in the JAXB package? Anyone see anything like it elsewhere?