My REST contorller:
@GetMapping("/test")
public Page<MyObject> pathParamTest(Pageable pageable) {
return myService.getPage(pageable);
}
I send a request like following:
localhost:8091/endpoint/test?page=0&size=3&sort=id&direction=DESC
It's my response from server:
{
"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
}
but the request has still direction = ASC.
How can I send to server direction = DESC?
And why response has a field "last" = true, because next page has one element more?
-
No, I didn't find nothing about my problem. When I write phrases: "spring pagination", "spring pageable" I get articles from '14 using ModelView.user– user2017年06月26日 10:13:03 +00:00Commented Jun 26, 2017 at 10:13
-
Oh, okey. I forgot that everyone is an expert. Forgive that you had to write this post... Pathetic...user– user2017年06月26日 10:20:59 +00:00Commented Jun 26, 2017 at 10:20
-
I have an additional question closely related to this one if anyone knows the answer, but I don't think this is possible. How do we pass the ignoreCase param on the query? I hoped it would be as simple as:- curl -v "localhost:8080/people/search/…" but it's not :-(AndyRED– AndyRED2020年04月27日 07:57:34 +00:00Commented Apr 27, 2020 at 7:57
1 Answer 1
try localhost:8091/endpoint/test?page=0&size=3&sort=id,DESC
from 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.