How to query data out of the box using Spring data JPA by both Sort and Pageable?

后端 未结 6 1654
别那么骄傲
别那么骄傲 2020-12-12 12:50

I am trying Spring data JPA in my project. I want to know if there is an out-of-the-box API to query data, by both Sort and Pageable. Of course, I

6条回答
  •  鱼传尺愫
    2020-12-12 13:34

    Spring Pageable has a Sort included. So if your request has the values it will return a sorted pageable.

    request: domain.com/endpoint?sort=[FIELDTOSORTBY]&[FIELDTOSORTBY].dir=[ASC|DESC]&page=0&size=20

    That should return a sorted pageable by field provided in the provided order.

提交回复
热议问题