displayTag学习摘要

1.tableTag中name属性:值默认作用域:request <display:table name="accList"> 如果作用域为session,则<display:table name="sessionScope.accList"> tableTag中指定ID属性会把该对象加入到pageContext对象中去。如ID="test" <%int cate=((Role)pageContext.getAttribute("test")).getCategory();%> 生成表格的序列号 例如:<display:table id="row" name="mylist"> <display:column title="序列号"><%=pageContext.getAttribute("row_rowNum")%>< /display:column> 如行号:row_rowNum <c:out value="${row_rowNum}"/> firstName:row.firstName   <c:out value="${row.firstName}"/> lastName: row.lastName  全部由ID来取得

2.限制页面显示的结果集数 1)全部<display:table name="accList" class="its" id="test"> 2)头5个<display:table name="accList" class="its" id="test" length="5"> 3)从第二个开始,显示下5个<display:table name="accList" class="its" id="test" offset="2" length="5">

3.包装器decorators,有行包装器(必须继承TableDecorator)和列包装器(必须实现ColumnDecorator)   在tableTag中显示list时,decorators中的方法会在list前调用,如果decorators实现类中有相关的getXXX()方法 时,调用此方法,如果没有,则直接调用list   在columnTag中显示value时,decorators中的方法会先调用,(应该重用)

4.传递参数,有两种方式,   一。struts方式:有以下几个属性   1)href 基本的超连接   2)paramId 添加到url上的参数名   <display:column property="status" href="details.jsp" paramId="id" paramProperty="id" />   3)paramName 传递容器内的其它bean当作参数 如:request.setAttribute("testparam", "sendamail");   <display:column property="email" href="details.jsp" paramId="action" paramName="testparam" paramScope="request" />   4)paramScope 指定bean的作用域   二。decorators方式   类Wrapper方法:

public String getLink1()        {                ListObject lObject= (ListObject)getCurrentRowObject();                int lIndex= getListIndex();                return "<a href=\"details.jsp?index=" + lIndex + "\">" + lObject.getId() + "</a>";        }

标签:

<display:table name="sessionScope.details" decorator="org.displaytag.sample.Wrapper" >  <display:column property="link1" title="ID" />  <display:column property="email" /></display:table>

5.分页   指定属性:pagesize="10" 每页显示10条记录

6.排序 1)在list中封装的对象的属性要实现Comparable接口,(一般均实现了) 2) 在columnTag中指定sortable="true"   可指定默认排序的列 defaultsort="1" 数值为第几列默认排序 defaultorder="descending" 指定默认为降序

7.导出 支持下列格式:'html', 'xml', 'csv', and 'excel'.   属性:export="true",注意导出无效,当使用jsp:include or the RequestDispatcher   <display:column media="csv excel" title="URL" property="url"/>   指定该url属性值只能在csv、excel中导出   需要指定export filter.

8.更改默认设置   1)通过<display:setProperty name=... value=...> 标签,可以覆盖一些默认设置   2)创建displaytag.properties文件,所有时区共用,建中文编码则创建displaytag_zh_cn.properties,放 到类路径下,jar包内共有两个默认的属性文件TableTag.properties,message.properties

9其它  

1)当多个表在一页显示时,每个表都想要有分页、排序、导出等功能时,只需为每个table指定一个不同的ID即可。  

2)增加表头<display:caption>角色管理</display:caption>  

3)增加表尾  <display:footer><tr><td colspan="6" align="center" >国瑞数码版权所有</td></tr></display:footer>  

4)http和email自动链接功能,指定autolink="true"  

5)指定一列显示的最大长度,避免太长把表格变形 maxLength="10" style="whitespace: nowrap;"  

6)当列的值为null,使用nulls="false"属性把null转为空白 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值