Spring mvc 整合PageHelper

Integer page=queryBean.getPage();
Integer pageSize=queryBean.getPageSize();
response.setContentType("text/xml");
response.setCharacterEncoding("UTF-8");
//返回当前页面的数据信息
HashMap<String, Object> map = new HashMap<String, Object>();

//添加PageHelpler分页

// startPage(第几页, 多少条数据)
com.github.pagehelper.Page<Object> pages=PageHelper.startPage(page, pageSize);
// Mybatis查询方
List<Application> allApplicationList = applicationService.queryApplicationList(queryBean);
// 用PageInfo对结果进行包装
PageInfo pageInfo = pages.toPageInfo();
//设置中文值
setApplicationListValue(allApplicationList);
map.put("rows", pageInfo.getList());
map.put("total", pageInfo.getPages());
map.put("totalCount",pageInfo.getTotal());

WriteJsonUtil.writejson(map, response);

猜你喜欢

转载自www.cnblogs.com/DylanZ/p/9023357.html