[英]how to get http jersey response status before parsing to dto?
我的代碼曾經是:
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
時,如何獲取http結果代碼
您將如何獲得此身份?
您沒有理由無法同時閱讀客戶響應和實體正文。
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);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.