我的代码曾经是:
ClientResponse clientResponse = webResource.path("routingRequest")
.queryParam("at", rr.at)
.get(ClientResponse.class);
我补充说:
RoutingResponse routingResponse = webResource.path("routingRequest")
.queryParam("at", rr.at)
.get(ClientResponse.class)
.getEntity(RoutingResponse.class);
如果我甚至没有得到ClientResponse.class
你怎么会得到这个状态?
答案 0 :(得分:2)
没有理由不能同时读取客户端响应和实体主体。
ClientConfig cc = new DefaultClientConfig();
cc.getProperties().put(
ClientConfig.PROPERTY_FOLLOW_REDIRECTS, true);
Client c = Client.create(cc);
WebResource r = c.resource("https://my_url");
ClientResponse response = r.get(ClientResponse.class);
EntityTag e = response.getEntityTag();
String entity = response.getEntity(String.class);
System.out.println("The response status is " + response.getStatus());
System.out.println("The enttiy body is " + entity);