赞
踩
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.3</version>
</dependency>
pagehelper:
helperDialect: mysql
reasonable: true
supportMethodsArguments: true
params: count=countSql
//查询页面所有数据
List<Employee> queryForList(Object query);
/分页查询(page是list集合)
Page<Employee> queryForPage(Object query);
impl
@Override
public Page<Employee> queryForPage(Object query) {
//设置当前页,和每页条数
PageHelper.startPage(1, 10);
//查询获得所有页数
List<Employee> employees = employeeMapper.queryForList(query);
//强转
Page<Employee> page = (Page<Employee>)employees;
return page;
}
mapper.xml
<select id="queryForList" resultType="cn.itsource.springboot.domain.Employee">
select
id,
username,
password
from t_employee
</select>
controller
//分页查询
@RequestMapping("/page")
@ResponseBody
public Page<Employee> queryForList(){
//需要放一个query进去
return employeeService.queryForPage(new Object());
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。