回 帖 发 新 帖 刷新版面

主题:struts的logic:iterate问题.

能不能再帮我看看以下的logic:iterate循环怎么写?

<% java.util.HashMap map = new java.util.HashMap();

   MyBookBean book = new MyBookBean();
   book.setBookIsbn("123456789");
   book.setBookName("J2EE");
   map.put(book.getBookIsbn,book);

   book = new MyBookBean();
   book.setBookIsbn("987654321");
   book.setBookName("Struts");
   map.put(book.getBookIsbn,book);

   request.setAttribute("shoppingCar",map);
%>
<logic:present name="shoppingCar">      <%--这里怎么写能够循环输出ISBN和书名--%>
   <logic:iterate id="abook" name="shoppingCar" property="value">
      <tr>
         <td>
             <bean:write name="abook" property="bookIsbn"/>
         </td>
         <td>
             <bean:write name="abook" property="bookName"/>
         </td>
      </tr>
    </logic:iterate>         
</logic:present>

回复列表 (共2个回复)

沙发

property应该=要迭代的内容

板凳

<logic:present name="shoppingCar">      <%--这里怎么写能够循环输出ISBN和书名--%>
   <logic:iterate id="abook" name="shoppingCar" scope="session" type="MyBookBean">
      <tr>
         <td>
             <bean:write name="abook" property="bookIsbn"/>
         </td>
         <td>
             <bean:write name="abook" property="bookName"/>
         </td>
      </tr>
    </logic:iterate>         
</logic:present>

我来回复

您尚未登录,请登录后再回复。点此登录或注册