1. Add dependencies
Find the version of pagehelper in maven
Add dependencies in pom
<dependency> <groupid>com.github.pagehelper</groupid> <artifactid>pagehelper-spring-boot-starter</artifactid> <version>1.2.2</version> </dependency>
2 , use
Many articles on the Internet will say that you need to configure application.properties
In fact, it is not necessary at all, the default settings already meet most needs
You can use it directly
@RequestMapping(value = "getApps.do") public String getApps(Apps apps) { PageHelper.startPage(apps.getPageNum(), apps.getPageSize()); ArrayList<apps> appsList = appsService.getApps(apps); PageInfo<apps> appsPageInfo = new PageInfo(appsList); return JSON.toJSONString(appsPageInfo); }</apps></apps>
PageHelper.startPage (the number of pages to be displayed, the number of each page to display);
The next line follows the query statement, not allowed Write something else, otherwise it will have no effect.
PageHelper.startPage(apps.getPageNum(), apps.getPageSize()); ArrayList<apps> appsList = appsService.getApps(apps);</apps>
This only has a paging effect, and there is no detailed information about the total number of pages.
If there is a demand for the number of pages, etc., you need to add The following line
PageInfo<t> appsPageInfo = new PageInfo(appsList);</t>
thus meets all paging requirements
The above is the detailed content of How does Springboot integrate the pagehelper paging function?. For more information, please follow other related articles on the PHP Chinese website!