gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 15:53:54 25 4
gpt4 key购买 nike

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

希望这有帮助。

关于java - 如何在struts 2中显示从db到jsp页面的多行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5455691/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com