반응형
250x250
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- Spring Error
- 도커
- java bigdecimal
- JavaScript
- codedeploy
- Jenkins
- Python
- codebuild
- Spring
- chart.js
- IntelliJ
- bootstrap
- aws
- Kafka
- codedeploy error
- COALESCE
- Flux
- node
- redis
- VPN
- kubeflow
- Airflow
- or some instances in your deployment group are experiencing problems.
- aws cicd
- SQL
- PostgreSQL
- chartjs
- codepipeline
- docker
- AWS CI/CD 구축하기
Archives
- Today
- Total
Small Asteroid Blog
PageRequest - PageableDefault 설정 변경 본문
728x90
PageRequest 생성자를 이용한 pageable 사용법이다.
생성자 | 설명 |
PageRequest(int page, int size) | 페이지 번호(0부터 시작), 페이지당 데이터의 수 |
PageRequest(int page, int size, Sort.Direction direction, String … props) | 페이지 번호, 페이지당 데이터의 수, 정렬 방향, 속성(칼럼)들 |
PageRequest(int page, int size, Sort sort) | 페이지 번호, 페이지당 데이터의 수, 정렬 방향 |
Pageable paging = PageRequest.of(0, 10, Sort.Direction.ASC, "id");
PageRequest pageRequest = PageRequest.of(curPage, size,Sort.Direction.fromString(sort), head);
PageRequest pageRequest = PageRequest.of(curPage, size,Sort.by(Sort.Direction.fromString(sort),head));
Controller에서 여러 정렬 조건을 사용하기 위해선 아래와 같이 사용하면 된다.
@PageableDefault(size = 10) @SortDefault.SortDefaults({
@SortDefault(sort = "paymentYear", direction = Sort.Direction.DESC),
@SortDefault(sort = "paymentMonth", direction = Sort.Direction.DESC)}) Pageable pageable
page는 0부터 시작한다.
728x90
반응형
'백엔드 > Spring' 카테고리의 다른 글
[spring] querydsl 동적쿼리 (0) | 2021.09.10 |
---|---|
[spring] Page 1 of 1 containing UNKNOWN instances (0) | 2021.09.06 |
Querydsl like, contains 차이 (0) | 2021.09.06 |
[spring] Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true (0) | 2021.08.24 |
HttpURLConnection HttpsURLConnection구분 (0) | 2021.08.20 |