使用Spring RestTemplate处理多部分/混合响应

时间:2016-02-12 13:00:18

标签: java spring multipart resttemplate

我正在对返回多部分/混合有效负载的端点进行休息调用。

这是使用Spring的RestTemplate的调用:

ResponseEntity<String> res = template.exchange(queryStr, HttpMethod.GET, entity, String.class);

我知道我可以从ResponseEntity中获取整个body作为String,但我不想手动解析它。是否有更优雅的方式来处理multipart / mixed的解析。我尝试过这样的事情:

ResponseEntity<MultipartFile> res = template.exchange(queryStr, HttpMethod.GET, entity, MultipartFile.class);

但我得到了这个例外:

  

org.springframework.web.client.RestClientException无法提取响应:没有为响应类型找到合适的HttpMessageConverter [interface org.springframework.web.multipart.MultipartFile]和内容类型[multipart / mixed; boundary = ML_BOUNDARY_10842596526049964806]

思想?

0 个答案:

没有答案