Jersey客户端java.util.List<;POJO>;自动转换器
我有这样的资源:Jersey客户端java.util.List<;POJO>;自动转换器,jersey,Jersey,我有这样的资源: @GET @Path("/todos") @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public List<Cliente> getListagem() { @GET @路径(“/todos”) @产生({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) 公共列表getListagem(){ 我的客户是: Cl
@GET
@Path("/todos")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public List<Cliente> getListagem() {
@GET
@路径(“/todos”)
@产生({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
公共列表getListagem(){
我的客户是:
ClientResponse response1 = wr.accept(MediaType.APPLICATION_XML).get(ClientResponse.class);
List<Cliente> colecao = response1.getEntity(List.class);
ClientResponse response1=wr.accept(MediaType.APPLICATION_XML).get(ClientResponse.class);
List colecao=response1.getEntity(List.class);
它产生了错误
Grave:找不到Java类Java.util.List、Java类型接口Java.util.List和MIME媒体类型application/xml的消息体读取器
我想知道为什么jersey成为XML中的列表,而客户端无法自动转换它?
解决这个问题的最佳方法是什么?
关于..在服务器上尝试以下操作:
publicjresponse getListagem(){
列表响应=。。。。。。;
返回JResponse.ok(response.build();
}
在客户机上:
Client=Client.create();
WebResource=client.resource(“http://localhost:8080/service");
List colecao=resource.accept(MediaType.APPLICATION_XML).get(new-genericype(){});
客户端如何获取列表?您不必修改服务器上的类型。该客户端代码适用于我。