Spring Boot integrated Pagehelper paging plugin

Source: Internet
Author: User

Spring Boot Integrated Pagehelper Paging Plugin

Test environment:

Spring Boot version 2.0.0.m7

MyBatis Starter Version 1.3.1

JDK 1.8


1. Maven introduces Pagehelper related jar packages
        <!--Paging plugin Pagehelper -        <Dependency>            <groupId>Com.github.pagehelper</groupId>            <Artifactid>Pagehelper</Artifactid>            <version>5.0.0</version>        </Dependency>        <Dependency>            <groupId>Com.github.pagehelper</groupId>            <Artifactid>Pagehelper-spring-boot-autoconfigure</Artifactid>            <version>1.2.3</version>        </Dependency>        <Dependency>            <groupId>Com.github.pagehelper</groupId>            <Artifactid>Pagehelper-spring-boot-starter</Artifactid>            <version>1.2.3</version>        </Dependency>        <!--Paging plugin Pagehelper -
2. The service layer code simply adds a core paging code (to be preceded by a DAO call)

Parameter page is the current page number, pagesize shows how many records per page

     Public int int page) {        pagehelper.startpage (page,pagesize);          return userdao.userslist ();    }
3. Controller layer code in the Pagehelper encapsulated PageInfo class package Returns the list result of a query, such as a red font
    @GetMapping ("/users")    publicint int page) {                List< userentity> list = userservice.userslist (loginname,pagesize,page);        PageInfo  <UserEntity> pageinfo = new Pageinfo<userentity>  (list);        Log.debug ("The method is ending");         return pageinfo;    }

After debugging the next breakpoint, the result of displaying pageinfo is

All the information has been displayed out of the page plug-in loading success!

Spring Boot integrated Pagehelper paging plugin

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.