【发布时间】:2011-07-24 06:20:32
【问题描述】:
我是 struts 2 的新手,我想显示从数据库表到 jsp 文件的多行。如何传递或设置属性来获取jsp页面中的行。
【问题讨论】:
我是 struts 2 的新手,我想显示从数据库表到 jsp 文件的多行。如何传递或设置属性来获取jsp页面中的行。
【问题讨论】:
这是我经常使用的方法:
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...
}
RowBean 是一个JavaBean,对应一行结果集。
使用下面的代码段来提取jsp页面上的内容:
<s:iterator value="displayList">
<tr>
<td>attribute1</td><td>attribute2</td>...<td>attributeN</td>
</tr>
</s:iterator>
其中attribute1 ... attributeN 与RowBean 中定义的属性相同。
希望这会有所帮助。
【讨论】: