日期:2014-05-17 浏览次数:20791 次
/** * 跳转到用户查询 * * @return */ @Action(value = "/manager/toUserList", results = { @Result(name = "SUCCESS",type="freemarker", location = "/WEB-INF/manager/user/userList1.ftl") }) public String toUserList() { try { PageResults<ManagerUserEntity> result = this.managerUserService.findTManagerUserByPage(user, getPageBean()); this.setUserList(result); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); this.setMsg(URLUtils.encode(e.getMessage(), "UTF-8")); return "ERROR"; } return "SUCCESS"; }
public class Serch extends ActionSupport { private String bid; private String bname; private int number; private int k;//储存最大页面数 private int pageNow=1; //页码数,初始为1 private int pageSize = 5 ; //页面行数 private int intRowCount;//总行数 private int intPageCount;//总页数 private int lastPage; private int p=1; .....set/get; public String execute() throws Exception { List list=new List(); java.util.List L=new ArrayList(); L=list.list(); intRowCount=L.size(); System.out.println("链表的长度:"+L.size()); if(L.size()%pageSize==0) //判断分多少页 this.lastPage=L.size()/pageSize; else this.lastPage=L.size()/pageSize+1; this.setIntPageCount(this.lastPage);//存入总页数 if(this.pageNow<1)//如果当前页码是第一页在点第一页的时候也跳转到第一页 this.pageNow=1; if(this.pageNow>this.lastPage)//同理只不过是最后一页 this.pageNow=this.lastPage; /* * * 假设取其中20-25条 * * * */ int startIndex=(this.pageNow-1)*pageSize;//截止条目开始,第20条 int endIndex=startIndex+pageSize;//截止条目结束 第25条 if(endIndex>=L.size()) endIndex=L.size(); L= L.subList(startIndex, endIndex); System.out.println("执行"); ActionContext.getContext().put("list", L); return "success"; } @Override public void validate() { // TODO Auto-generated method stub super.validate(); } } 前台显示: 共<s:property value="intRowCount"/>记录 共<s:property value="intPageCount"/>页 第<s:property value="pageNow"/>页 <s:url action="Serch.action" id="url"> <s:param name="pageNow"> <s:property value="1" /> </s:param> </s:url> <s:a href="%{url}">首页</s:a> <s:url action="Serch.action" id="url"> <s:param name="pageNow"> <s:property value="%{pageNow-1}" /> </s:param> </s:url> <s:a href="%{url}">上一页</s:a> <s:url action="Serch.action&