这篇文章主要介绍了Spring Boot 中pageHelper 插件使用配置及实现思路,通过引入myabtis和pageHelper依赖,在yml中配置mybatis扫描和实体类,具体实现方法跟随小编一起看看吧
使用思路
1.引入myabtis和
pageHelper依赖2.yml中配置mybatis扫描和
实体类这2行
代码pageNum:当前第几页pageSize:
显示多少条数据userList:
数据库查询的数据数据列表
pageHelper.startPage(pageNum, pageSize);PageInfo pageInfo = new PageInfo(userList);最后返回
一个pageInfo 对象即可,pageInfo 这个对象中只有数据一些信息,但是,没有成功失败的状态或者
提示语。真实企业中会封装
一个返回对象,把pageInfo 放到对象中
1.pom依赖
方法一:使用原生的
pageHelper1.在pom.xml中引入依赖,刷新
自动加载jarcom.github.
pageHelperpageHelper5.2.1
方法二 本人使用
pageHelper的starter1.导入pom.xml依赖com.github.
pageHelperpageHelper-
spring-boot-starter1.2.122.在application.properties或者application.yml格式配置
pageHelper的
属性二选一#
pageHelper分页插件配置application.properties
pageHelper.helper-dialect=
MysqL pageHelper.reasonable=true
pageHelper.support-methods-arguments=true
pageHelper.p
arams=count=count
sqlapplication.ymlhe
pageHelper: lperDialect:
MysqL reasonable: true supportMethodsArguments: true p
arams: count=count
sqlController层
调用 测试@RequestMapping("findallCar") public String findallCar(Model model, HttpSession session) {
pageHelper.startPage(1,5); List carTables = service.findallCar(); PageInfo page = new PageInfo(carTables); Sy
stem.out.println(page); model.addAttribute("c
arall", carTables); session.setAttribute("c
aralls", carTables); return "carinsert"; }
pageHelper.startPage(1,5); List carTables = service.findallCar(); PageInfo page = new PageInfo(carTables); Sy
stem.out.println(page);到此这篇关于Spring Boot 中
pageHelper 插件使用配置思路详解的
文章就介绍到这了,更多相关Spring Boot
pageHelper 插件内容请
搜索编程之家以前的
文章或继续浏览下面的相关
文章希望大家以后多多
支持编程之家!