JqGrid实现分页
业务层代码
@Override
@Transactional(propagation = Propagation.SUPPORTS)
public Map<String, Object> queryAll(Integer page, Integer rows) {//page->页码 rows->每页显示条数
User user = new User();
//start 每页起始条数下标
int start = (page - 1) * rows;
//参数列表 (每页起始下标,每页显示条数)
RowBounds rowBounds = new RowBounds(start, rows);
//分页查询 查询当前页条数信息
List<User> list = userDao.selectByRowBounds(user, rowBounds);
//查询总条数
int count = userDao.selectCount(user);
//总页数
int totalPage = count % rows == 0 ? count / rows : count / rows + 1;
Map map = new HashMap();
//当前页条数信息
map.put("rows", list);
//总条数
map.put("records", count);
//页码
map.put("page", page);
//总页数
map.put("total", totalPage);
return map;
}