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 “按啥条件排序可空”)
网友评论