зеркало из
https://github.com/iharh/notes.git
synced 2025-10-29 20:56:06 +02:00
40 строки
1.9 KiB
Plaintext
40 строки
1.9 KiB
Plaintext
https://docs.spring.io/spring-data/commons/docs/current/api/org/springframework/data/domain/PageRequest.html
|
|
https://docs.spring.io/spring-data/commons/docs/current/api/org/springframework/data/domain/Pageable.html
|
|
ofSize(pageSize) - first page...
|
|
https://docs.spring.io/spring-data/commons/docs/current/api/org/springframework/data/domain/Page.html
|
|
int getTotalPages
|
|
https://docs.spring.io/spring-data/commons/docs/current/api/org/springframework/data/domain/Slice.html
|
|
if we don't need total number of items/pages
|
|
https://docs.spring.io/spring-data/commons/docs/current/api/org/springframework/data/util/Streamable.html
|
|
toList()
|
|
|
|
Pageable firstPageWithTwoElements = PageRequest.of(0, 2);
|
|
Pageable secondPageWithFiveElements = PageRequest.of(1, 5);
|
|
|
|
Pageable sortedByName =
|
|
PageRequest.of(0, 3, Sort.by("name"));
|
|
Pageable sortedByPriceDesc =
|
|
PageRequest.of(0, 3, Sort.by("price").descending());
|
|
Pageable sortedByPriceDescNameAsc =
|
|
PageRequest.of(0, 5, Sort.by("price").descending().and(Sort.by("name")));
|
|
|
|
2019
|
|
https://reflectoring.io/spring-boot-paging/
|
|
https://github.com/thombergs/code-examples/tree/master/spring-boot/paging
|
|
at Configuration add @EnableSpringDataWebSupport
|
|
SpringDataWebAutoConfiguration
|
|
SpringDataWebProperties
|
|
https://github.com/spring-projects/spring-data-commons/blob/main/src/main/java/org/springframework/data/web/PageableHandlerMethodArgumentResolver.java
|
|
https://github.com/spring-projects/spring-data-commons/blob/main/src/main/java/org/springframework/data/web/SortHandlerMethodArgumentResolver.java
|
|
props:
|
|
spring.data.web.pageable.size-parameter=size
|
|
spring.data.web.pageable.page-parameter=page
|
|
spring.data.web.pageable.default-page-size=20
|
|
spring.data.web.pageable.one-indexed-parameters=false
|
|
spring.data.web.pageable.max-page-size=2000
|
|
spring.data.web.pageable.prefix=
|
|
spring.data.web.pageable.qualifier-delimiter=_
|
|
|
|
@PagableDefault
|
|
@SortDefault
|