gpt4 book ai didi

Spring分页-请求参数

转载 作者:行者123 更新时间:2023-12-04 03:06:27 43 4
gpt4 key购买 nike

我的 REST Controller :

    @GetMapping("/test")
public Page<MyObject> pathParamTest(Pageable pageable) {
return myService.getPage(pageable);
}

我发送如下请求:
localhost:8091/endpoint/test?page=0&size=3&sort=id&direction=DESC

这是我服务器的回复:
{
"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
}

但是请求仍然有方向= ASC。

如何发送到服务器方向 = DESC?

为什么响应有一个字段“last”=true,因为下一页还有一个元素?

最佳答案

尝试
localhost:8091/endpoint/test?page=0&size=3&sort=id,DESC

来自 spring data rest 6.2. Sorting

curl -v "http://localhost:8080/people/search/nameStartsWith?name=K&sort=name,desc"

sort Properties that should be sorted by in the format property,property(,ASC|DESC). Default sort direction is ascending. Use multiple sort parameters if you want to switch directions, e.g. ?sort=firstname&sort=lastname,asc.

关于Spring分页-请求参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44757218/

43 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com