Springboot使用RestTemplate发送Post请求postForEntity (application/json)


String param = '[1424,2255]';
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity request = new HttpEntity(param, headers);
ResponseEntity str  = restTemplate.postForEntity(url,request,String.class);
log.debug("End request interface, the response is {}",str);
String json = str.getBody();