struts2 、mybatis 、easyui 分页
rows
page
控件自动提交这两个参数
pageSize number The page size. 10
pageNumber number Show the page number when pagination is created. 1
pageList array User can change the page size. The pageList property defines how many size can be changed. [10,20,50,100]
action
/** * easyui获取APP信息 * */ public String getAppList() { dataMap = appService.getApp(rows, page); return "json"; } public String getRows() { return rows; } public void setRows(String rows) { this.rows = rows; } public String getPage() { return page; } public void setPage(String page) { this.page = page; } public Map<String, Object> getDataMap() { return dataMap; } public void setDataMap(Map<String, Object> dataMap) { this.dataMap = dataMap; }
serviceImpl
public Map<String, Object> getApp(String rows, String page) { // 分页信息 int pageNo = Integer.parseInt((page == null || page == "0") ? "1" : page); int pageSize = Integer.parseInt((rows == null || rows == "0") ? "10" : rows); Map<String, Object> dataMap = new HashMap<String, Object>(); dataMap.put("total",appMapper.countByExample(null)); dataMap.put("rows", appMapper.selectByExample( null, new RowBounds((pageNo - 1) * pageSize,pageSize))); //org.apache.ibatis.session.RowBounds.RowBounds(int offset, int limit) return dataMap; }