Struts2的iterator标签

Struts2的iterator标签

  • s:iterator:迭代的是值栈中的数据

    • value 属性: 写的ognl表达式

    • var 属性 :

      1. 写了:把迭代出来的集合的对象暂时放入ContextMap,迭代完之后删除
      2. 没写:把迭代出来的集合的对象暂时放入值栈,迭代完之后弹栈

写了var属性

把迭代出来的集合的对象暂时放入ContextMap,迭代完之后删除

<s:iterator value="customers" var="cust">
<TR style="FONT-WEIGHT: normal; FONT-STYLE: normal; BACKGROUND-COLOR: white; TEXT-DECORATION: none">
    <TD>${cust.custName } - <s:property value="#cust.custName"/>TD>
    <TD>${cust.custLevel }TD>
    <TD>${cust.custSource }TD>
    <TD>${cust.custIndustry }TD>
    <TD>${cust.custAddress }TD>
    <TD>${cust.custPhone }TD>
    <TD>
    <a href="${pageContext.request.contextPath }/customer/CustomerServlet?method=editCustomerUI&custId=${cust.custId}">修改a>
      
    <a href="${pageContext.request.contextPath }/customer/CustomerServlet?method=removeCustomer&custId=${cust.custId}">删除a>
    TD>
TR>   
s:iterator>

没有写var属性的

把迭代出来的集合的对象暂时放入值栈,迭代完之后弹栈,

遍历一个弹栈一个

<s:iterator value="customers" >
<TR style="FONT-WEIGHT: normal; FONT-STYLE: normal; BACKGROUND-COLOR: white; TEXT-DECORATION: none">
    <TD>${custName } - <s:property value="custName"/>TD>
    <TD>${custLevel }TD>
    <TD>${custSource }TD>
    <TD>${custIndustry }TD>
    <TD>${custAddress }TD>
    <TD>${custPhone }TD>
    <TD>
    <a href="${pageContext.request.contextPath }/customer/CustomerServlet?method=editCustomerUI&custId=${custId}">修改a>
      
    <a href="${pageContext.request.contextPath }/customer/CustomerServlet?method=removeCustomer&custId=${custId}">删除a>
    TD>
TR>
s:iterator>

你可能感兴趣的:(struts2)