STRUTS+HIBERNATE的分页(用的是STRUTS里的分页)二

STRUTS+HIBERNATE的分页(用的是STRUTS里的分页)二
ShowlistAction 处理请求然后根据 具体进行分页 //Created by MyEclipse Struts // XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_4.0.1/xslt/JavaClass.xsl package com.xiaozhi.pagebean; import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.struts.action.Action; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import com.xiaozhi.user.User; /** * MyEclipse Struts * Creation date: 04-06-2006 * * XDoclet definition: * @struts.action input="/errors/errors.jsp" validate="true" */ public class ShowlistAction extends Action { public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) { User us = new User() ; List list = us.select_find() ; request.setAttribute("list",list) ; String pn = request.getParameter("pn"); if(pn == null) { pn = "0" ; } int page = Integer.parseInt(pn) ; System.out.println("#############"+page+"###########") ; //创建分页实例 PageBean pb = new PageBean() ; //设置每页显示的数目 pb.setEverypage(3) ; //先设置最多有多少个数据 根据他得到一共有多少页 pb.setCountdata(list.size()) ; //设置当前页面 pb.setCurrentPage(page) ; request.setAttribute("pbs",pb) ; return mapping.findForward("show"); } }

你可能感兴趣的:(STRUTS+HIBERNATE的分页(用的是STRUTS里的分页)二)