RestTemplate

RestTemplate 发送 get 方法

RestTemplate restTemplate = new RestTemplate();
restTemplate.getMessageConverters().add(new FastJsonHttpMessageConverter());
HttpHeaders requestHeaders = new HttpHeaders();
requestHeaders.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
List<MediaType> list = new ArrayList<MediaType>();
list.add(MediaType.TEXT_HTML);
requestHeaders.setAccept(list);
HttpEntity<String> requestEntity = new HttpEntity<String>(null, requestHeaders);
ResponseEntity<Long> response = restTemplate.exchange(sbf.toString(), HttpMethod.GET, requestEntity, Long.class);

return response.getBody();

  

 

posted @ 2019-03-01 19:26  xiluhua  阅读(196)  评论(0编辑  收藏  举报