美文网首页
Spring Boot 集成PageHelper

Spring Boot 集成PageHelper

作者: DamonYi | 来源:发表于2018-06-26 18:51 被阅读306次

    1、在pom中引入PageHelper依赖

    2、通过@Configuration 和@Bean 配置PageHelper属性

    ##

    package com.itmayidu.config;

    import com.github.pagehelper.PageHelper;

    import org.springframework.context.annotation.Bean;

    import org.springframework.context.annotation.Configuration;

    import java.util.Properties;

    /**

    * Created by Damon on 2018/6/26_17:25.

    *

    * @Descrption:

    */

    @Configuration

    public class PageHelperConfig {

    @Bean

        public PageHelper pageHelper(){

            PageHelper pageHelper =new PageHelper();

            Properties p =new Properties();

            p.setProperty("offsetAsPageNum","true");

            p.setProperty("rowBoudsWithCount","true");

            p.setProperty("resonable","true");

            pageHelper.setProperties(p);

            return pageHelper;

    }

    }

    ##

    3、在controller中调用PageHelper.startPage(int 开始第几页,int 每页展示几个数据,String “按啥条件排序可空”)

    相关文章

      网友评论

          本文标题:Spring Boot 集成PageHelper

          本文链接:https://www.haomeiwen.com/subject/xkwmyftx.html