您的位置:首页 > 编程语言 > Java开发

struts2 、mybatis 、easyui 分页

2016-08-06 07:28 190 查看
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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: