unirest代码看起来像
HttpResponse<String> response = Unirest.get("url")
.header("Accept", "application/json")
.header("X-WMI", "code")
.asString();
相应的restemplate代码编写如下
HttpHeaders headers = new HttpHeaders();
headers.set("X-WMI", wmi);
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
headers.set("Content-Type", "application/json");
HttpEntity<HttpHeaders> entity = new HttpEntity<>(headers);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url);
ResponseEntity<String> response = this.restTemplate.exchange(
builder.toUriString(), HttpMethod.GET, entity, String.class);
return response.getBody();
检查了这些数值,它们看起来完好无损。
有人能告诉我哪里不对吗。
暂无答案!
目前还没有任何答案,快来回答吧!