其他分享
首页 > 其他分享> > resttemplate使用记录1

resttemplate使用记录1

作者:互联网

使用resttemplate批量上传文件

MultiValueMap multiValueMap = new LinkedMultiValueMap();
for (String file : files) {
FileSystemResource resource = new FileSystemResource(new File(file));
multiValueMap.add(file, resource);
}
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.MULTIPART_FORM_DATA);
HttpEntity<MultiValueMap> body = new HttpEntity<>(multiValueMap, httpHeaders);

JSONArray jsonArray = restTemplate.postForObject(postUrl, body, JSONArray.class);


标签:body,记录,resttemplate,multiValueMap,file,使用,new,httpHeaders
来源: https://www.cnblogs.com/siyuaxh/p/15036484.html