我最近开始使用带有PagingAndSortingRepository的spring-boot。
@RepositoryRestResource(collectionResourceRel = "foobar", path = "foobar")
public interface MyRepository extends PagingAndSortingRepository<FooEntity, Long>{
List<FooEntity> findAllByStatusIn(@Param("stati") Collection<Integer> stati);
}
如何通过findAllByStatusIn
http://localhost:8080/foobar/search/findAllByStatusIn?stati={3,1}
我已经尝试过了:
http://localhost:8080/foobar/search/findAllByStatusIn?stati=(3,1)
http://localhost:8080/foobar/search/findAllByStatusIn?stati=[3,1]
http://localhost:8080/foobar/search/findAllByStatusIn?stati={3,1}
http://localhost:8080/foobar/search/findAllByStatusIn?stati=3,1
答案 0 :(得分:0)
稍微修改我的PagingAndSortingRepository后:
@RepositoryRestResource(collectionResourceRel = "pstnachrichten", path = "pstnachrichten")
public interface PSTNachrichtenRepository extends PagingAndSortingRepository<PSTNachrichtenEntity, Long>{
List<PSTNachrichtenEntity> findAllByStatusIn(@Param("stati") int... stati);
}
我能够按如下方式调用资源:
http://localhost:8080/foobar/search/findAllByStatusIn?stati=3&stati=1
因此,诀窍是重复网址中的名称值对。