RestTemplate发送get请求并携带请求头
//设置请求头
HttpHeaders headers = new HttpHeaders();
headers.add("X-Access-Token", huaWenToken);
//封装请求头
HttpEntity<MultiValueMap<String, Object>> formEntity = new HttpEntity<MultiValueMap<String, Object>>(headers);
RestTemplate restTemplate = new RestTemplate();
//发送请求并返回JSONObject
JSONObject jsonObject = restTemplate.exchange("http://www.baidu.com", HttpMethod.GET, formEntity, JSONObject.class).getBody();