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");
}
转载请注明原文地址:https://ipadbbs.8miu.com/read-41781.html