参考:https://blog.csdn.net/asahinokawa/article/details/86497531
https://blog.csdn.net/clj198606061111/article/details/70227571
https://blog.csdn.net/u010180738/article/details/61439630
GET加headers:
HttpHeaders httpHeaders =new HttpHeaders();
httpHeaders.set("head1", "head1");
httpHeaders.set("head2", "head2");
String url = "https://test.com/api";
ResponseEntity response =restTemplate.exchange(url, HttpMethod.GET,new HttpEntity(httpHeaders), String.class);
PUT带返回值:
HttpHeaders httpHeaders =new HttpHeaders();
httpHeaders.setContentType(MediaType.APPLICATION_XML);
httpHeaders.set("head1", "head1");
httpHeaders.set("head2", "head2");
String url = "https://test.com/api";
String body= "body";
HttpEntity entity =new HttpEntity<>(body, httpHeaders);
String url = "https://test.com/api";
ResponseEntity response =restTemplate.exchange(url, HttpMethod.PUT, entity, String.class);