我想使用logic:iterator和bean:write标签把查询数据库的结果输出到jsp页面中去这是我写的Action类的一部分:
public ActionForward userManage(...)
{
    AdminForm AdminForm = (AdminForm) form;
    ResultSet rs;
    String SQLString = "SELECT * FROM administrator";
    rs = DBOperation.DBQuery(SQLString);
    List result = new ArrayList();
    while(rs.next())
    {
        result.add(rs.getString("admin_id")); 
    }
    request.setAttribute("result", result);
    return mapping.findForward("userManage");
}
也就是把结果集转化成了List然后setAttribute在JSP页面中:
  <body>
   <table>
<tr>
<td width="150" align="center">用户ID</td>
<td width="150" align="center">用户密码</td>
</tr>
<logic:iterate id="action" indexId="ind" name="result">
<td><html:multibox property="selectedactions">
<bean:write name="action" property="admin_id"/> 
</html:multibox><%=Integer.parseInt(ind.toString())+1%></td>
</tr>
</logic:iterate>
</table>
  </body>
我想要把搜索出的admin_id这一列的数据输出到jsp页面中,但是bean:write标签的property属性总是有问题,我不确定property里应该填写什么,而且似乎无论填什么都会报错no getter method in bean action。我不明白action这个bean的getter方法应该到哪里去定义……请各位帮帮我这菜鸟……如果这个问题解决了还有进一步的问题:
这样做只是输出结果集中特定的一列数据,如果我想要输出所有数据,应该怎么做?

解决方案 »

  1.   

    <bean:write name="action" property="admin_id"/> 
    针对JavaBean name=“bean的名称(放在四种作用域)”
        property=“bean中的属性”
        bean基本的方法就是getter和setter。<bean:write name="action" property="admin_id"/>
    用EL替换${action}
      

  2.   

    很显然的基础错误,在<bean:write name="action" property="admin_id"/> 这句话的时候就已经出错了.而且错误是没有getter方法.因为你查询出来的结果你是直接往LIST里面ADD的.而没有把结果封装到一个JavaBean里面.把查询结果取出来后.封装到一个JavaBean中.并且提供GET SET方法.就可以.
      

  3.   

    在你的action里面。没有把result放入你的formbean里面,你的formbean里面没有result的get,set方法,所以<logic:iterate id="action" indexId="ind" name="result">是找不到你的那个result.
      

  4.   

    <bean:write name="action" /> 因为个action本身就是一个String,所以不用再写属性了吧