首页 > 技术文章 > RestTemplate请求

zt007 2017-03-06 17:30 原文

JSONObject json = new JSONObject(sendParam);
HttpHeaders headers = new HttpHeaders();
MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
headers.setContentType(type);
HttpEntity<String> reqE = new HttpEntity<String>(json.toString(), headers);
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<Map> result = restTemplate.exchange(url, HttpMethod.POST, reqE, Map.class);

推荐阅读