天天看點

RestTemplate請求

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);

轉載于:https://www.cnblogs.com/zt007/p/6511041.html