Spring分页-请求参数
我的休息控制器:Spring分页-请求参数,spring,rest,spring-mvc,Spring,Rest,Spring Mvc,我的休息控制器: @GetMapping("/test") public Page<MyObject> pathParamTest(Pageable pageable) { return myService.getPage(pageable); } 这是我从服务器得到的响应: { "content": [ { "id": 1 }, { "i
@GetMapping("/test")
public Page<MyObject> pathParamTest(Pageable pageable) {
return myService.getPage(pageable);
}
这是我从服务器得到的响应:
{
"content": [
{
"id": 1
},
{
"id": 2
},
{
"id": 3
}
],
"last": true,
"totalPages": 1,
"totalElements": 3,
"first": true,
"sort": [
{
"direction": "ASC",
"property": "id",
"ignoreCase": false,
"nullHandling": "NATIVE",
"descending": false,
"ascending": true
}
],
"numberOfElements": 3,
"size": 3,
"number": 0
}
但是请求仍然具有direction=ASC
如何发送到服务器direction=DESC
为什么响应有一个字段“last”=true,因为下一页还有一个元素?试试看
localhost:8091/endpoint/test?page=0&size=3&sort=id,DESC
从
旋度-v
“”
对格式中应按排序的属性进行排序
属性,属性(,ASC | DESC)。默认排序方向为升序。使用
如果要切换方向,请使用多个排序参数,例如。
排序=姓氏&排序=姓氏,asc
不,我没有发现我的问题。当我写短语:“SpringPagination”,“SpringPageable”时,我使用ModelView获得了14年的文章。哦,好的。我忘了每个人都是专家。原谅你不得不写这篇文章。。。可怜……如果有人知道答案的话,我还有一个与此密切相关的问题,但我认为这是不可能的。如何在查询中传递ignoreCase参数?我希望它会像:-curl-v“”一样简单,但它不是:-(
{
"content": [
{
"id": 1
},
{
"id": 2
},
{
"id": 3
}
],
"last": true,
"totalPages": 1,
"totalElements": 3,
"first": true,
"sort": [
{
"direction": "ASC",
"property": "id",
"ignoreCase": false,
"nullHandling": "NATIVE",
"descending": false,
"ascending": true
}
],
"numberOfElements": 3,
"size": 3,
"number": 0
}