首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

兑现“上一页”“第几页”“下一页”(当前页数从Action中获取)

2013-08-20 
实现“上一页”“第几页”“下一页”(当前页数从Action中获取)package cn.ict.mp.webserviceimport java.util.H

实现“上一页”“第几页”“下一页”(当前页数从Action中获取)
package cn.ict.mp.webservice;import java.util.HashMap;import java.util.List;import java.util.Map;import org.apache.struts2.ServletActionContext;import cn.ict.mp.bean.UserInfo;import cn.ict.mp.service.DataManage;import com.opensymphony.xwork2.ActionSupport;public class ActionUserList extends ActionSupport {/** * */private static final long serialVersionUID = -6652169340293756648L;private Map<String, Object> dataMap = new HashMap<String, Object>();public Map<String, Object> getDataMap() {return dataMap;}private Integer pageNo;private Integer totalSize;private Integer totalPage; private Integer pageSize = 5; public Integer getTotalPage() {return totalPage;} public Integer getPageNo() {return pageNo;} public void setPageNo(Integer pageNo) {this.pageNo = pageNo;} public String execute() throws Exception {/** * 定义action返回格式 */ServletActionContext.getResponse().setContentType("application/json;charset=UTF-8");ServletActionContext.getResponse().setCharacterEncoding("UTF-8"); //分页显示用户信息列表List<UserInfo> dataList = DataManage.getUserList(pageNo, pageSize);totalSize = DataManage.getUserListSize();//总页数向上取整totalPage = (int)Math.ceil((double)totalSize/pageSize);this.dataMap.put("userList", dataList);return SUCCESS;}}

?

热点排行