【问题标题】:how to display multiple rows from db to jsp page in struts 2如何在struts 2中显示从db到jsp页面的多行
【发布时间】:2011-07-24 06:20:32
【问题描述】:

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

【问题讨论】:

    标签: java database struts2


    【解决方案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 中定义的属性相同。

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 2013-09-27
      • 1970-01-01
      • 1970-01-01
      • 2012-04-20
      • 2011-08-07
      • 2012-02-24
      • 1970-01-01
      • 1970-01-01
      • 2013-09-11
      相关资源
      最近更新 更多