Skip to content

Instantly share code, notes, and snippets.

@logicjwell
Created April 26, 2019 10:45
Show Gist options
  • Save logicjwell/65b68816bf369f8a67c380cd9cfc1951 to your computer and use it in GitHub Desktop.
Save logicjwell/65b68816bf369f8a67c380cd9cfc1951 to your computer and use it in GitHub Desktop.
[springboot中PageHelper配置与使用] #pagehelper #springboot
1.配置:
pagehelper:
reasonable: false
params:
page-num: pageHelperStart
page-size: pageHelperRows
count: countSql
offset-as-page-num: true
support-methods-arguments: true
helper-dialect: mysql
row-bounds-with-count: true
reasonable为true时,如果查询的页码超出了总页码,则显示最后一页数据,如果查询的页码少于第一页,则显示首页的数据。
2. 编码
在执行mapper查询方法前,插入下面代码:
PageHelper.startPage(currentPage,pageSize);
生成查询结果后,使用PageInfo生成分页结果:
PageInfo<QueryGuaranteedPaymentsResp> pageInfo = new PageInfo<>(guaranteedPayments);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment