【发布时间】:2014-02-20 05:57:34
【问题描述】:
假设我有一个简单的 Person 类,其名称和姓氏作为属性。还假设我有一个简单的休息服务,它带有返回人员列表的 get 端点。
public class Person {
// name and last name properties plus getters and setters
}
// Service
@Stateless
@LocalBean
@Path("test")
public class SimpleRestService {
//Suppose people is initialized and contains actual people
private ArrayList<Person> people;
@GET
@PATH("/people/iterable")
public Iterable<Person> getPeople(){
//This one works
return people;
}
@GET
@PATH("/people/collection")
public Collection<Person> getPeople(){
//This one fails. HTTP 500. Nothing on server.log ...
return people;
}
}
第一个端点 test/people/iterable 可以正常工作,而 test/people/collection 会因 HTTP 500 而失败。有人对此有所了解吗?
【问题讨论】:
标签: java collections jersey jax-rs iterable