其他分享
首页 > 其他分享> > Springboot使用RestTemplate发送Post请求postForEntity (application/json)

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

标签:String,headers,RestTemplate,postForEntity,request,application,json,str
来源: https://www.cnblogs.com/xiaolaodi1999/p/14237251.html