spring数据休息+自定义方法:分页,排序不起作用

时间:2014-09-17 11:04:18

标签: spring spring-data-jpa spring-data-rest

所以我的界面:

public interface SubmissionRepository extends PagingAndSortingRepository<Submission, Long> {
//all by approval phase
@RestResource(path="byApprovalPhase")
List<Submission> findByApprovalPhase(@Param("approvalPhase") ApprovalPhase approvalPhase);
//paging + sorting
@RestResource(path="byApprovalPhasePaging")
Page<Submission> findByApprovalPhase(@Param("approvalPhase") ApprovalPhase approvalPhase, Pageable pageable);
//all with sorting
@RestResource(path="byApprovalPhaseSorting")
List<Submission> findByApprovalPhase(@Param("approvalPhase") ApprovalPhase approvalPhase, Sort pageable);
}

所以我在json / hal curl -v http://localhost:8080/submissions/search

中获取这些方法
....
"_links" : {
"findByApprovalPhase" : [ {
  "href" : "http://localhost:8080/submissions/search/byApprovalPhase{?approvalPhase}",
  "templated" : true
}, {
  "href" : "http://localhost:8080/submissions/search/byApprovalPhasePaging{?approvalPhase,page,size,sort}",
  "templated" : true
}, {
  "href" : "http://localhost:8080/submissions/search/byApprovalPhaseSorting{?approvalPhase}",
  "templated" : true
} ]
}
...

但是curl -v http://localhost:8080/submissions/search/byApprovalPhasePaging?approvalPhase=PENDING&page=1&size=5

返回默认的20行。排序相同 - 它不起作用(没有错误,只是排序没有效果)。不知道这里错过了什么。

//编辑:

localhost类似的东西:8080 /提交 - 总共有14行,默认情况下显示20行。 curl -v http://localhost:8080/submissions?size=1会返回第一个,但curl -v http://localhost:8080/submissions?page=1&size=1仅返回_的链接到prev,接下来。

我的存储库扩展了PagingAndSortingRepository ..

1 个答案:

答案 0 :(得分:1)

傻事......我们不得不使用&#34;&#34;使用卷曲进行测试时,在网址周围..否则它会在&amp;之后处理所有内容。作为其他参数..更多细节appending multiple querystring variables with curl