如何在 Spring Data REST 导出的端点中使用列表?

How to use List in endpoint exported by Spring Data REST?

我有 2 个对象,Foo 和 Bar(一个 Foo 是带有 Bar 的 @ManyToOne),Spring Boot 2.0 中的一个非常基本的存储库接口,以及一个方法:

   List<Foo> findByBarIn(@Param("bar") List<Bar> bar);

这被 Spring 映射到名为 /foos/search/findByBarIn

的端点

我可以指定一个柱状图来做类似

的事情

GET http://host/foos/search/findByBarIn?bar=http://host/bars/33(其中 33 是​​ Bar 实体的 ID)

但是,如何指定多个柱?

我尝试过:(没有成功)

获取http://host/foos/search/findByBarIn?bar=http://host/bars/33,http://host/bars/44

获取http://host/foos/search/findByBarIn?bar=http://host/bars/33&bar=http://host/bars/44

我已经知道怎么做了:

所以,这个原型没有工作:

List<Foo> findByBarIn(@Param("bar") List<Bar> bars);

但这确实:

List<Foo> findByBarIn(@Param("bar") Bar... bars);

然后,我可以通过以下方式指定多个柱:

GET http://host/foos/search/findByBarIn?bar=http://host/bars/33&bar=http://host/bars/44