how to display multiple rows from db to jsp page in struts 2
I am a newbie in struts 2, I want to display multiple rows from a database table to a jsp file. How开发者_运维技巧 to pass or set the properties to get the the rows in jsp page.
This is the method I often use:
public class anAction {
private list displayList<RowBean>;
... the setter/getter for displayList and get the rows from JDBC resultset into the displayList somewhere in the code...
}
The RowBean is a JavaBean that corresponds to a row of resultset.
The use the following code segment to extract the content on the jsp page:
<s:iterator value="displayList">
<tr>
<td>attribute1</td><td>attribute2</td>...<td>attributeN</td>
</tr>
</s:iterator>
where the attribute1 ... attributeN are the same as the attributes defined in the RowBean.
Hope this helps.
精彩评论