• pagehelper是一个在GitHub上开源的项目,可以帮你方便进行mybatis分页
  •  
  • 在springboot 的配置文件上面有dialect属性,用来配置你是什么数据库,4.0版本之后能自动检测
  •  
  • com.github.pagehelper.parser.Parser接口,配置到dialect属性上面
  •  
  • 需要pagehelper.jar和jsqlparser.jar   这个两个jar包
  •  
  • 使用方法

           

           调用PageHelper.startPage(int a,int b)静态方法,紧跟在这个方法后的第一个Mybatis查询方法会进行分页,后面的不会分页,除非再次调用

 

           jsp中如何使用,分页时,实际返回结果List是Page<E>,如果想取出分页信息,需要强制转换Page<E>,或者使用PageInfo类,里面包含很多分页信息,都是github开源的.

 

           然后例如点击下一页

           

<a href="${pageContext.request.contextPath}/emps?pn=${pageInfo.pageNum+1}" aria-label="Next">

           在controller里面有emps这个映射方法,后面传一个参数就可以分页查询了

Springboot,mybatis,pagehelper学习笔记

相关文章:

  • 2021-08-29
  • 2021-11-16
  • 2021-10-27
  • 2022-02-11
  • 2022-03-03
  • 2021-06-19
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-11
  • 2021-11-16
  • 2021-05-16
  • 2022-02-25
  • 2021-07-11
  • 2022-12-23
  • 2021-11-30
相关资源
相似解决方案