iterate标签通常支持是List,Map,数组等,你可以将for(;iterator.hasNext();)
存到一个List里面,然后再用iterate标签来显示

解决方案 »

  1.   

    我不会的是:list里是一个个类对象,你看我的源码,想取出对象内容首先要进行强制转换的。 for (;iterator.hasNext();) {
    out.print ("result ...");
    MemberTable table = (MemberTable) iterator.next();
    out.print (table.getId());
    out.print ("  ");
    out.print (table.getName());
    out.print ("  ");
    out.print (table.getPassword());
    out.print ("  ");
    out.print (table.getQuestion());
    out.print ("  ");
    out.print (table.getAnswer());
    }
      

  2.   

    最好不要把 business logic 的东西放在 jsp 中,这样不符合 struts 的原则
      

  3.   

    那么怎处理好?
    使用 hibernate 持久化类得到数据集(java.util.List或java.util.Iterator)后,怎么把它用jsp页面显示出来?
      

  4.   

    这还不简单,这样写就行了
    <bean:define id="list" name="FormName" property="detailsList" scope="request" />
    <logic:iterate id="table" collection="<%=list%>" name="list">
    <TD><bean:write name="table" property="id"/></TD>
    <TD><bean:write name="table" property="name"/></TD>
    <TD><bean:write name="table" property="password"/></TD>
    <logic:iterate/>
      

  5.   

    问题解决:
    <html:html locale="true">
    <head>
    </head><body>
    <center>

    <%--
    <logic:iterate name="the name which set by setAttribute() method" 
                   id="the name that you will use in repetition of <logic:iterate></logic:iterate>"
                   type="the class name of the objects in collection"
                   scope="request | page | session | application"/>
    --%> <table border="1" width="100%">
    <logic:iterate name="memberList" id="xxx" scope="page" type="creatxr.demos.struts.services.db.MemberTable">
    <tr>
    <td width="25%"><bean:write name="xxx" property="id"/></td>
    <td width="25%"><bean:write name="xxx" property="name"/></td>
    <td width="25%"><bean:write name="xxx" property="password"/></td>
    <td width="25%"><bean:write name="xxx" property="question"/></td>
    <td width="25%"><bean:write name="xxx" property="answer"/></td>
    </tr>
    </logic:iterate>
    </table>
    <center>
    <body>
    </html:html>