【发布时间】:2011-02-11 18:31:49
【问题描述】:
我需要创建一个下拉菜单,我需要在其中显示来自数据库的 5 个帐号。我打算做的是,将这 5 个帐号设置为数组列表,然后该列表将保存在会话常量中。这个常量需要从我的 JSP 中获取。
在我的行动课上 -
HttpSession session = request.getSession();
ArrayList accts = new ArrayList();
String acct1 = data.getAccountId1();
String acct2 = data.getAccountId2();
accts.add(acct1);
accts.add(acct2);
session.setAttribute(
WorkConstants.TEST1,
accts);
TEST1 被定义为公共字符串,如下所示:
public String TEST1 = "Test1";
在我的jsp中我是这样编码的。
<td valign="top">
1. accounts<span class="bodyCopy"><font color="#ff0000"> * </font></span>:
<br/>
<html:select name="MyDataForm" property="accountNumber"
styleClass="formContent">
<html:options collection="<%= WorkConstants.TEST1 %>"
property="value" labelProperty="label" styleClass="formContent"/>
</html:select>
<br/>
</td>
但这不起作用。 出现错误 - 名称 Test1 下的 bean 的属性值没有可用的 getter 方法。看起来我的数组值没有设置到 TEST1 中。 为什么?
【问题讨论】: