org.springframework.web.client包下的RestTemplate
RestTemplate的post请求
//请求头
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
//请求体
JSONObject jsonObject = new JSONObject();
jsonObject.put("fileID", "88ac1493aed3d01e0ea2ead3e10bb7eb.jpg");
HttpEntity<String> requestEntity = new HttpEntity<String>(jsonObject.toJSONString(), headers);
//执行请求
ApiResponse response = restTemplate.postForObject(wmConfig.getOss_server() + "/ossDownloadObject", requestEntity, ApiResponse.class);
if (response != null && response.getStatus().equals(ApiResponse.SUCCESS_CODE)) {
JSONObject jsonObject1 = (JSONObject) JSON.toJSON(response.getBody());
String url = jsonObject1.getString("url");
}