<dependency> <groupId>com.ithub.pagehelper</groupId> <artifactId>pagehelper-spring-boot-starter</artifactId> <version>1.2.12</version> </dependency>
pagehelper: helperDialect: mysql spportMethodsArguments: true
在查询前使用分页插件,原理:统一拦截sql,为其提供分页功能
PageHelper.startPage(page,pageSize); //查询List List list = mapper.selextListxxx(xxx); //封装返回结果 PageInfo<?> pageList = new PageInfo<>(list); PagedGridResult grid = new PagedGridResult(); grid.setPage(page); grid.setRows(list); grid.setTotal(pageList.getPages()); grid.setRecords(pageList.getTotal()); return grid;