【发布时间】:2019-06-05 03:07:09
【问题描述】:
我们有一个 rest 服务,它返回一个类型为 map 的字节数组。如果我在没有泛型的情况下使用 Map,则在接收响应时,字节数组数据将转换为字符串。是否可以仅从服务器发送字节数据,如果可以,如何使用 RestTemplate 从客户端检索该数据?
ResponseEntity<Map<String, byte[]>> result result = restTemplate.exchange("http://localhost:8085/api/fetchContent?Id=" + contentId+"&userName=trump", HttpMethod.GET, entity, Map.class, params);
上面的代码会产生一个编译问题,因为返回类型是一个映射。
【问题讨论】:
标签: rest spring-boot resttemplate