zhaojuan8 发表于 2013-1-29 07:48:13

(原创)show下本人的分页组件

<span style="font-family: Wingdings;" />       PagerTag.tld 标签的验证文件
page.css 分页的样式文件
pager1.2_bug修正.jar 分页的源代码(代码比较乱,没有做优化)
l         在项目种导入pager包,page.css样式表, PagerTag.tld(一般放在web-info下)三个文件
l         Pager pager=new Pager(int 每页显示数目,int 总记录条数,String 当前页);
a)         注意第三个参数可以用request.getParameter(“page”)获取
b)        request.setAttribute("page", pager);将pager放入request作用域,名字不能错
l         下面看看页面使用情况
a)       假如PagerTag.tld是放在WEB-INF下的,在jsp头需要加上
<%@ taglib prefix="zyc" uri="/WEB-INF/PagerTag.tld" %>
其中prefix是可以随便起的
b)       需要导入page.css样式表文件
c)       看看页面使用
<zyc:page url="index1.do"  style="digg" />
url就是要请求的action的地址
style是选取的样式默认如果什么都没写默认是default
样式一共又25种digg、yahoo、meneame、flickr、sabrosus、scott、quotes、black、black2、grayr、yellow、jogger、starcraft2、tres、megas512、technorati、yahoo2、msdn、badoo、manu、green-black、viciao、youtube、black-red、default
     修正了不能放置参数的bug
在页面使用参数时候的使用方法:如下有一个TestBean对象
public class TestBean {
    private int id;
    private String name;
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
}
Action代码
public ActionForward execute (ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response ) {
        Pager pager=new Pager(20,400,request.getParameter("page"));
        request.setAttribute("page", pager);
        TestBean bean=new TestBean();
        bean.setId(1);
        bean.setName("崴脚鸭");
        request.setAttribute("bean",bean);
        return mapping.findForward("test");
    }
页面代码
<%@ page language="java" pageEncoding="gbk" contentType="text/html; charset=gbk" %>
<%@ taglib prefix="zyc" uri="/WEB-INF/PagerTag.tld" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html lang="true">
  <head>
        <title>Pager标签测试</title>
     <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">   
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <link rel="stylesheet" type="text/css" href="style/page.css">
  </head>
 
  <body>   
    <zyc:page url="index1.do&id=#"  style="yahoo"/>
    <zyc:page url="index1.do&name=#&method=init"  style="digg"/>
      </body>
</html:html
页: [1]
查看完整版本: (原创)show下本人的分页组件