springboot+mybatis整合分页插件PageHelper

1.在pom.xml中引入依赖:

    <dependency>
        <groupId>com.github.pagehelper</groupId>
        <artifactId>pagehelper</artifactId>
        <version>5.0.0</version>
    </dependency>
    <dependency>
        <groupId>com.github.pagehelper</groupId>
        <artifactId>pagehelper-spring-boot-autoconfigure</artifactId>
        <version>1.2.3</version>
    </dependency>
    <dependency>
        <groupId>com.github.pagehelper</groupId>
        <artifactId>pagehelper-spring-boot-starter</artifactId>
        <version>1.2.3</version>
    </dependency>
    <!--分页插件-->

2.在application.propreties加入配置:

pagehelper.helperDialect=mysql pagehelper.reasonable=true
pagehelper.supportMethodsArguments=true
pagehelper.params=count=countSql

3.在controller层中应用

    @GetMapping(value="getListByMap")
public List<ZhuanyeInfo> getListByMap (
        @RequestParam(value="currentPage",required=false,defaultValue="1")Integer currentPage,
        @RequestParam(value="pageSize",required=false,defaultValue="10")Integer pageSize
) throws ParseException {
   
    PageHelper.startPage(currentPage , pageSize);
    List<ZhuanyeInfo> list = zhuanyeService.getListByMap(map);        
    PageInfo<ZhuanyeInfo> pageList = new PageInfo<ZhuanyeInfo>(list); 
    List<ZhuanyeInfo> datas = pageList.getList(); 
    return datas;
}
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客
应支付0元
点击重新获取
扫码支付

支付成功即可阅读