锁定老帖子 主题:(原创)show下本人的分页组件
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2008-11-19
最后修改:2008-11-19
PagerTag.tld 标签的验证文件 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=#[bean.id]" style="yahoo"/> <zyc:page url="index1.do&name=#[bean.name]&method=init" style="digg"/> </body> </html:html 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2008-11-19
louzhu有没有struts2的版本啊?
|
|
返回顶楼 | |
发表时间:2008-11-20
jxausea 写道 louzhu有没有struts2的版本啊? 目前是基于Struts1的版本struts2我没试过 |
|
返回顶楼 | |
发表时间:2008-11-20
不喜欢tag,闪。
|
|
返回顶楼 | |
发表时间:2008-11-20
参数是怎么传的?
|
|
返回顶楼 | |
发表时间:2008-11-20
不喜欢tag,基于tag的组件比如Richfaces,Icefaces之类的已经很全面了,什么组件都有还是ajax无刷新的,个人觉得还是像ExtJS之类的客户端组件好
|
|
返回顶楼 | |
发表时间:2008-11-21
superxielei 写道 参数是怎么传的?
比如在Action 在request作用域放置了 TestBean bean=new TestBean(); bean.setId(1); bean.setName("崴脚鸭"); request.setAttribute("bean",bean); 那么在页面的url属性可以这样写 url="index1.do&myname=#[bean.name]&myid=#[bean.id]" 如果设置的是一个单纯的字符串 request.setAttribute("name","zyc"); 那么在页面的url属性可以这样写 url="index1.do&myname=#name" |
|
返回顶楼 | |
浏览 3782 次