RestTemplate创建如下: (HttpClientBuilder来自 org.apache.http.impl.client 。*)
CloseableHttpClient chc = HttpClientBuilder.create().disableRedirectHandling().build();
ClientHttpRequestFactory noRedirectFactory = new HttpComponentsClientHttpRequestFactory(chc)
RestTemplate restTemplate = new RestTemplate(noRedirectFactory);
使用如下:
ResponseEntity<String> response = restTemplate.getForEntity( ${url} , String.class);
int responseCode = response.getStatusCodeValue();
现在为$ {url}的3个案例,仅在查询参数中存在差异:
提前致谢。