struts标签小记

1.<s:iterator>标签的  奇偶数行使用不同样式

<s:iterator id="list" value="#request.listq" status="st">
     <s:if test="#st.odd">
     <dl>
         <p><img src="<%=serverContext %>/template/shop/images/dw/x.png" /></p>
            <dt><img src="<s:property value="#list.productImgPath" />" width="169px" height="168px"/></dt>
            <dd><span><s:if test="#list.isPublish==\"Y\"">
     <a href="<s:property value="#list.htmlPath"/>" target="_blank">
     <s:property value="#list.productName" />
     </a>
    </s:if></span></dd>
            <dd>万能险</dd>
            <dd>&nbsp;</dd>
            <dd style="color:#FC3"><strong>¥1000</strong>起</dd>
            <dd><a href="<s:property value="#list.htmlPath"/>" target="_blank"><img src="<%=serverContext %>/template/shop/images/dw/hy_ckxq.png" /></a></dd>
        </dl>
     
     </s:if>
     <s:else>
     <dl style="margin-right:-10px">
         <p><img src="<%=serverContext %>/template/shop/images/dw/x.png" /></p>  
            <dt><img src="<s:property value="#list.productImgPath" />" width="169px" height="168px"/></dt>
            <dd><span><s:if test="#list.isPublish==\"Y\"">
     <a href="<s:property value="#list.htmlPath"/>" target="_blank">
     <s:property value="#list.productName" />
     </a>
    </s:if></span></dd>
            <dd>万能险</dd>
            <dd>&nbsp;</dd>
            <dd style="color:#FC3"><strong>¥1000</strong>起</dd>
            <dd><a href="<s:property value="#list.htmlPath"/>" target="_blank"><img src="<%=serverContext %>/template/shop/images/dw/hy_ckxq.png" /></a></dd>
        </dl>
     
     </s:else>

2..<s:iterator>标签的  list对象嵌套  (private List<ClaimPayDetail> listClaimPayDetail 是ClaimDetail的一个属性)

<s:iterator id="claimlist" value="policy.claims">
               <s:iterator id="claimpaydetaillist" value="#claimlist.listClaimPayDetail">
              <tr>
                <td><s:property value="#claimlist.claimNumber"/></td>
                <td><s:property value="policy.policyNo"/></td>
                <td><s:property value="#claimlist.insuredName"/></td>
                <td><s:property value="#claimlist.claimState"/></td>
                <td><s:property value="#claimlist.closeDate"/></td>
                <td><s:property value="#claimlist.claimResult"/></td>
                <td><s:property value="#claimpaydetaillist.receiveMoney"/>元</td>
              </tr>
              </s:iterator>
              </s:iterator>

//还有其他状态的test

1:#status.odd 是否奇数行

2:#status.count 当前行数

3:#status.index 当前行的序号,从0开始『#status.count=#status.index+1』

4:#status.first 是否第一行

5:#status.last 是否最后一行

6:#status.modules(int) 当前行数取模

判断方法是:

<s:iterator value="list" status="st">

<s:if test="#status.last">

........

</s:if>

</s:iterator>

在前台JSP页面判断list是否为空

<s:if test="list.size()==0">list为空</s:if>

<s:else>

  <s:iterator value="list">

    名字:<s:property value="name"/> 性别:<s:property value="sex"/>

  </s:iterator>

</s:else>

上一篇:【MySQL】记一次线上重大事故:二狗子竟然把线上数据库删了!!


下一篇:CSS3 Media Query实现响应Web设计(宽度为不同的移动设备)