SpringBoot集成Mybatis分页插件PageHelper

1.注入依赖

	
		com.github.pagehelper
		pagehelper-spring-boot-starter
		1.2.9
	

2. 配置 application.yml

  #pagehelper分页配置 
  pagehelper:
    helperDialect: mysql
    reasonable: true
    supportMethodsArguments: true
    params: count=countSql

3.Controller层使用

public interface ArticleMapper {

    @Select("select * from tb_article")
    public List
getArticleById (); } public String pageArticle(@RequestParam(defaultValue = "1")Integer pageNum, @RequestParam(defaultValue = "10")Integer pageSize,Model model ){ PageHelper.startPage(pageNum,pageSize); List
article = articleService.getArticleIndex(); PageInfo
alist = new PageInfo
(article); model.addAttribute("alist",article); }

你可能感兴趣的:(数据库)