如何从球衣服务端点发送实体列表?

How to send the list of entities from the jersey service endpoint?

我正在从球衣服务器发送实体列表。在客户端,我正在尝试获取这些实体列表。但它给出了解组异常。

为什么要在元素名称的末尾添加 's',即 "emps" 而不是 "emp"。

@XmlRootElement
public class Emp{
...
}

Server side code:
@POST
    @Path("/getallemps")
    @Produces(MediaType.APPLICATION_XML)
    @Consumes(MediaType.APPLICATION_XML)
    public List<Emp> getAllEmployees2(@Context HttpServletRequest request, @Context HttpServletResponse response) throws IOException{
        List<Emp> el = new ArrayList<Emp>();
....
return el;
}

client side code:
public void testGetAllEmployees(){
        String res = null;
        ClientConfig config = new DefaultClientConfig();
        Client client = Client.create(config);
        WebResource resource = client.resource(uri);
...
ClientResponse response = resource.type(MediaType.APPLICATION_XML).post(ClientResponse.class);
        List<Emp> li = response.getEntity(new GenericType<List<Emp>>(Emp.class));
}

Exception is:
....unmarshalexception unexpected element(url="" local="emps") expected element {}emp

而不是response.getEntity(new GenericType<List<Emp>>(Emp.class));

使用response.getEntity(new GenericType<List<Emp>>(){});

不太清楚为什么前者不起作用,但我用后者测试过,它工作正常。