概述
import com.github.pagehelper.Page;
需要导入的jar Controller
import com.github.pagehelper.PageInfo;
@RequestMapping(value = "/getMoreBook",produces="application/json;charset=utf-8")//处理返回中文乱码
@ResponseBody
public String getMoreBook(String type,String majorCate,@RequestParam(required = false,defaultValue = "1")String page) {
PageInfo books=new PageInfo();
books=bookServiceImpl.getMoreBook(type,majorCate,page);
JSONObject jsObj= new JSONObject();
jsObj.put("status",1);
jsObj.put("msg","ok");
jsObj.put("content",books);
return jsObj.toString();
}
Service
PageInfo getMoreBook(String type, String majorCate, String page);
ServiceImpl
public PageInfo getMoreBook(String type, String majorCate, String page){
try {
PageHelper.startPage(Integer.parseInt(page), 10);
List books = bookMapper.getMoreBook(type,majorCate);
PageInfo pageInfo = new PageInfo(books);
return pageInfo;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
返回的数据格式
{
"content": {
"endRow": 100,
"firstPage": 6,
"hasNextPage": true,
"hasPreviousPage": true,
"isFirstPage": false,
"isLastPage": false,
"lastPage": 13,
"list": [{},{}],
"navigateFirstPage": 6,
"navigateLastPage": 13,
"navigatePages": 8,
"navigatepageNums": [6, 7, 8, 9, 10, 11, 12, 13],
"nextPage": 11,
"pageNum": 10,
"pageSize": 10,
"pages": 189,
"prePage": 9,
"size": 10,
"startRow": 91,
"total": 1884
},
"status": 1,
"msg": "ok"
}
最后
以上就是沉默可乐为你收集整理的pageinfo对合并list进行分页_PageInfo实现分页的全部内容,希望文章能够帮你解决pageinfo对合并list进行分页_PageInfo实现分页所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复