Get the App
SLTechnology News&Howtos  ›  Development  › 

How to integrate pagehelper paging function with Springboot

Shulou Source: shulou.com Published: 2022-06-01 00:46:46 11月13日 Update

This article mainly explains "Springboot how to integrate pagehelper paging function", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "Springboot how to integrate pagehelper paging function" bar!

Add dependencies

Find the version of pagehelper in maven

Add dependencies in pom

Com.github.pagehelper pagehelper-spring-boot-starter 1.2.2

2. Use

Many articles on the network will say that it needs to be configured in application.properties.

In fact, there is no need at all, and the default settings already meet most of the needs.

Just use it directly.

@ RequestMapping (value = "getApps.do") public String getApps (Apps apps) {PageHelper.startPage (apps.getPageNum (), apps.getPageSize ()); ArrayList appsList = appsService.getApps (apps); PageInfo appsPageInfo = new PageInfo (appsList); return JSON.toJSONString (appsPageInfo);}

PageHelper.startPage (the number of pages to be displayed and the number of pages to be displayed per page)

The next line is followed by the query statement, do not write anything else, otherwise there will be no effect.

PageHelper.startPage (apps.getPageNum (), apps.getPageSize ()); ArrayList appsList = appsService.getApps (apps)

This only has a paging effect, and there is no detailed information on the total number of pages and so on.

If you have a need for the number of pages, you need to add the following line

PageInfo appsPageInfo = new PageInfo (appsList)

This satisfies all the paging requirements.

At this point, I believe that everyone on the "Springboot how to achieve integration of pagehelper paging function" have a deeper understanding, might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Page function integration content effect quantity learning query practical deeper line information interest most practical practical easy to operate articles methods more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Shulou Technology MySQL MariaDB Microsoft