RestTemplate有一个方法,您可以在其中定义Interface
ResponseExtractor<T>,此接口用于获取响应的标头,一旦有了它们,就可以使用发送回来
HttpEntity并再次添加。
.add("cookie", "SERVERID=c52");尝试这样的事情。
String cookieHeader = null;new ResponseExtractor<T>(){ T extractData(ClientHttpResponse response) { response.getHeaders(); }}然后
HttpHeaders headers = new HttpHeaders(); headers.add("cookie", cookieHeader ); ResponseEntity<byte[]> response = restTemplate.exchange("http://example.com/file/123", GET, new HttpEntity<String>(headers), byte[].class);


