How do I POST a Pojo with Jersey Client without manually convert to JSON?

前端 未结 2 1924
感情败类
感情败类 2020-12-30 08:42

I have a working json service which looks like this:

@POST
@Path(\"/{id}/query\")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(JSON)
public ListWrapper qu         


        
2条回答
  •  天命终不由人
    2020-12-30 09:30

    If your web-service produces a JSON you must handle that in your client by using an accept() method:

    ClientResponse response = webResource.accept(MediaType.APPLICATION_JSON).post(searchQuery, MediaType.APPLICATION_JSON);
    ListWrapper listWrapper = response.getEntity(ListWrapper.class);
    

    Try this and give your results.

提交回复
热议问题