Springboot: i need help in explaining the Major method and emphasise on the pageables and how it is used to create a page in page response. ============================================= FeedRepo: public interface FeedRepository extends JpaRepository, PagingAndSortingRepository { PagefindByUser(Useruser,Pageablepageable); PagefindByUserNot(Useruser,Pageablepageable); } =========================================================== public class PageResponse { intpageNum; intpageSize; inttotalPages; Listcontent; publicPageResponse(Pagepaged){ if(Optional.ofNullable(paged).isPresent()){ this.pageNum=paged.getNumber(); this.pageSize=paged.getSize(); this.totalPages=paged.getTotalPages(); this.content=paged.getContent(); } } publicintgetPageNum(){ returnpageNum; } publicvoidsetPageNum(intpageNum){ this.pageNum=pageNum; } publicintgetPageSize(){ returnpageSize; } publicvoidsetPageSize(intpageSize){ this.pageSize=pageSize; } publicintgetTotalPages(){ returntotalPages; } publicvoidsetTotalPages(inttotalPages){ this.totalPages=totalPages; } publicListgetContent(){ returncontent; } publicvoidsetContent(Listcontent){ this.content=content; } }
Springboot:
i need help in explaining the Major method and emphasise on the pageables and how it is used to create a page in page response.
=============================================
FeedRepo:
public interface FeedRepository extends JpaRepository<Feed,Integer>, PagingAndSortingRepository<Feed,Integer> {
Page<Feed>findByUser(Useruser,Pageablepageable);
Page<Feed>findByUserNot(Useruser,Pageablepageable);
}
===========================================================
public class PageResponse<T> {
intpageNum;
intpageSize;
inttotalPages;
List<T>content;
publicPageResponse(Page<T>paged){
if(Optional.ofNullable(paged).isPresent()){
this.pageNum=paged.getNumber();
this.pageSize=paged.getSize();
this.totalPages=paged.getTotalPages();
this.content=paged.getContent();
}
}
publicintgetPageNum(){
returnpageNum;
}
publicvoidsetPageNum(intpageNum){
this.pageNum=pageNum;
}
publicintgetPageSize(){
returnpageSize;
}
publicvoidsetPageSize(intpageSize){
this.pageSize=pageSize;
}
publicintgetTotalPages(){
returntotalPages;
}
publicvoidsetTotalPages(inttotalPages){
this.totalPages=totalPages;
}
publicList<T>getContent(){
returncontent;
}
publicvoidsetContent(List<T>content){
this.content=content;
}
}
Step by step
Solved in 2 steps