First we need to use this pagehelper need to introduce the assistant jar package that we need, of course I personally Write detailed steps in the official website of this search pagehelper assistant
- Open official website https://pagehelper.github.io/ or click on the Baidu search pagehelper VIEW ON Github
-
Locate the following pagehelper Chinese version of the document click on how to use pagehelper find the location where the inside of the jar (which both a jar package does not match the version conflict prone to lead to a bunch of small series have not read the error so you can download below, the actual test can use)
https://oss.sonatype.org/content/repositories/releases/com/github/pagehelper/pagehelper/
pagehelper-5.1.10.jar
http://repo1.maven.org/maven2/com/github/jsqlparser/jsqlparser/
jsqlparser-2.0.jar
! <- plugins position in the configuration file must meet the requirements, otherwise it will error, in the following order: the Properties ?, Settings ?, typeAliases ?, typeHandlers ?, objectFactory, objectWrapperFactory ?,? Plugins ?, Environments ?, databaseIdProvider ?, mappers ? -> <plugins> <-! com.github.pagehelper to PageHelper class where the package name -> <plugin Interceptor = "com.github.pagehelper.PageInterceptor"> <-! use the following way configuration parameters, will be behind all the parameters introduced -> <Property name = "the param1" value = "VALUE1" /> </ plugin> </ plugins>
Can be used in java
-
// Get Page 1 of 10 content, the total number of queries by default COUNT PageHelper.startPage (1 and 10); List <Country> = countryMapper.selectAll List (); // PageInfo with the results packaging PageInfo page = new PageInfo ( List); // test PageInfo all the attributes // PageInfo contains a very comprehensive paging properties assertEquals (1, page.getPageNum ()); assertEquals (10, page.getPageSize ()); assertEquals (1, page.getStartRow () ); the assertEquals (10, page.getEndRow ()); the assertEquals (183 is, page.getTotal ()); the assertEquals (. 19, page.getPages ()); the assertEquals (. 1, page.getFirstPage ()); the assertEquals (. 8, page.getLastPage ()); the assertEquals (to true, page.isFirstPage ()); the assertEquals (to false, page.isLastPage ()); the assertEquals (to false, page.isHasPreviousPage ()); the assertEquals (to true, page.isHasNextPage ());