我想使用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方法应该到哪里去定义……请各位帮帮我这菜鸟……如果这个问题解决了还有进一步的问题:
这样做只是输出结果集中特定的一列数据,如果我想要输出所有数据,应该怎么做?
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方法应该到哪里去定义……请各位帮帮我这菜鸟……如果这个问题解决了还有进一步的问题:
这样做只是输出结果集中特定的一列数据,如果我想要输出所有数据,应该怎么做?
针对JavaBean name=“bean的名称(放在四种作用域)”
property=“bean中的属性”
bean基本的方法就是getter和setter。<bean:write name="action" property="admin_id"/>
用EL替换${action}