AnNong。
2019-08-07 16:25
采纳率: 33.3%
浏览 6.8k
已采纳

restTemplate能否传递list集合?

如下,我想要直接传递list过去 然后在客户端处理list

 RestTemplate restTemplate = new RestTemplate();
            for (ScanFamily scanFamily : scanFamilyList) {
                String requestWebUrl = url;
                //获取档案列表
               List<ArchiveFile> archiveFileList =  this.archiveFileManager.searchList(scanFamily.getFamilyNo());
                //TODO  直接传递list
                MultiValueMap<String, Object> paramMap = new LinkedMultiValueMap<String, Object>();
                paramMap.add("archiveFileList",archiveFileList);
                String s = restTemplate.postForObject(requestWebUrl, paramMap, String.class);

但是它会一直报错:

org.springframework.http.converter.HttpMessageNotWritableException: Could not write request: no suitable HttpMessageConverter found for request type [java.util.ArrayList]
    at org.springframework.http.converter.FormHttpMessageConverter.writePart(FormHttpMessageConverter.java:292)
    at org.springframework.http.converter.FormHttpMessageConverter.writeParts(FormHttpMessageConverter.java:252)
    at org.springframework.http.converter.FormHttpMessageConverter.writeMultipart(FormHttpMessageConverter.java:242)
    at org.springframework.http.converter.FormHttpMessageConverter.write(FormHttpMessageConverter.java:194)
    at org.springframework.http.converter.FormHttpMessageConverter.write(FormHttpMessageConverter.java:1)
    at org.springframework.web.client.RestTemplate$HttpEntityRequestCallback.doWithRequest(RestTemplate.java:588)
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:436)
    at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:401)
    at org.springframework.web.client.RestTemplate.postForObject(RestTemplate.java:279)

1条回答 默认 最新

相关推荐 更多相似问题