【发布时间】:2018-11-05 22:13:10
【问题描述】:
我正在尝试查询https://transport.opendata.ch/ API。在此 API 中,可以过滤响应以避免大负载(使用 ?fields[]=...)。
我正在使用 Spring Boot 和 Feign,这是我的代码:
@FeignClient(value = "transport", url = "${transport.url}")
public interface TransportClient {
@RequestMapping(method = GET, value = "/connections", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
Connections getConnections(@RequestParam("from") String from, @RequestParam("to") String to, @RequestParam("fields[]") String[] fields);
default Connections getConnections(String from, String to) {
return getConnections(from, to, new String[] {"connections/from", "connections/to"});
}
}
问题在于生成的请求:
如您所见,url 已编码,数组未正确绑定(使用逗号而不是 url 中的多个 fields)。
有什么方法可以实现吗?如果使用 FeignClient (Spring) 无法完成,也许使用 Feign 是可能的?
感谢您的帮助。
【问题讨论】:
标签: arrays spring spring-boot spring-cloud-feign feign