文件名称:STRUCTS的简单分页设计
文件大小:2KB
文件格式:TXT
更新时间:2011-11-10 03:16:49
struts 分页
原创:
在action中查询结果集之后,把结果导入collection变量中。然后调用
public static String onlySplitPages(BaseForm form, int pp, int counts)
{
int rowsperpage=pp; //每页多少行,只有这个需要改。进入的页面需要一个?command=search&movpage=1
int pagenow=1;
int pageall;
form.getRequest().setAttribute("rowsperpage",new Integer(rowsperpage));
pageall=(counts+rowsperpage-1)/rowsperpage;
form.getRequest().setAttribute("PAGEALL",new Integer(pageall));
//如果传入movpage参数,则改变之,否则用session的(这样如果修改或删除记录,还可以回到本页而不是第1页)
String movpage = (String)form.getRequest().getParameter("movpage");
if (movpage==null)
{Integer II=(Integer)form.getRequest().getAttribute("PAGENOW");
if(II==null)pagenow=1;else pagenow=II.intValue();
};
if (movpage!=null)
{try { pagenow = Integer.parseInt(movpage); } catch (Exception e) { pagenow=1; }
};
if (pagenow<1)pagenow=1;
if (pagenow>pageall)pagenow=pageall;
form.getRequest().setAttribute("PAGENOW",new Integer(pagenow));
return "";
}
jsp网页中类似如下,可以改造直接跳转第几页