如何在struts 2中显示从db到jsp页面的多行

时间:2011-03-28 07:08:43

标签: java database struts2

我是struts 2中的新手,我想显示从数据库表到jsp文件的多行。如何传递或设置属性以获取jsp页面中的行。

1 个答案:

答案 0 :(得分:1)

这是我经常使用的方法:

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中定义的属性相同。

希望这有帮助。