//设置请求头
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
headers.add("Accept", MediaType.ALL_VALUE);
headers.add("token", token);
//根contenType的请求方式选择map
MultiValueMap<String, Object> forms = new LinkedMultiValueMap<String, Object>();
forms.put("codes", Collections.singletonList(code));
//添加地址
String batchExportUrl = urlConstant.EXPORT_PROCESS_DEFINITION;
// String result = restTemplateUtil.doPostForFormUrlencoded(batchExportUrl,token,forms);
RestTemplate restTemplate = new RestTemplate();
HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<MultiValueMap<String, Object>>(forms, headers);
ResponseEntity<byte[]> responseEntity = restTemplate.postForEntity(batchExportUrl, httpEntity, byte[].class);
System.out.println(responseEntity.getStatusCode());
byte[] bytes = responseEntity.getBody();
使用resttemplate下载文件
最新推荐文章于 2024-06-12 08:49:41 发布