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

String param = '[1424,2255]';
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<String> request = new HttpEntity<String>(param, headers);
ResponseEntity<String> str  = restTemplate.postForEntity(url,request,String.class);
log.debug("End request interface, the response is {}",str);
String json = str.getBody();
上一篇:java-Spring RestTemplate-基于http状态代码读取不同的对象类型?


下一篇:restTemplate使用