<%-- <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>
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());
}
使用 hibernate 持久化类得到数据集(java.util.List或java.util.Iterator)后,怎么把它用jsp页面显示出来?
<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/>
<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>