30

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?

asked Jun 26, 2017 at 10:01
3
  • No, I didn't find nothing about my problem. When I write phrases: "spring pagination", "spring pageable" I get articles from '14 using ModelView. Commented Jun 26, 2017 at 10:13
  • Oh, okey. I forgot that everyone is an expert. Forgive that you had to write this post... Pathetic... Commented 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 :-( Commented Apr 27, 2020 at 7:57

1 Answer 1

50

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.

GHajba
3,7215 gold badges28 silver badges38 bronze badges
answered Jun 26, 2017 at 10:09
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.