@Resource private RestTemplate restTemplate;
HttpHeaders headers = new HttpHeaders(); headers.add("Content-Type", "application/json");//对应headers内容
restTemplate.getForObject(url,String.class); restTemplate.postForObject(url,new HttpEntity<>(body, headers),String.class) //body对应Body内容 ,可以使用很多形式如,map,json等 restTemplate.postForObject(url,new HttpEntity<>(body, headers),String.class,map) //body对应Body内容 ,可以使很多形式如,map,json等 //map对应Params内容
url为调用网址,body若没有内容可以去掉。
满足常用get post的几种第三方调用接口了,