我确定我在做一些愚蠢的事情,但在过去的几天里,我一直很难在一个迭代器中填写我的复选框ArrayList
,该迭代器超过了Object
.
这是我的对象:
public class EmailObject {
int emailId;
String emailAddress;
public int getEmailId() {
return emailId;
}
public void setEmailId(int emailId) {
this.emailId = emailId;
}
public String getEmailAddress() {
return emailAddress;
}
public void setEmailAddress(String emailAddress) {
this.emailAddress = emailAddress;
}
}
在我的动作类中,我创建了一个ArrayList
上述EmailObject
s。
在我的 JSP 页面上,我可以通过 a 获取复选框checkboxlist
(但这对我不利,因为我希望它是垂直的并且不想与 Struts 样式混淆)
<s:checkboxlist name="selectedEmails" list="userEmails" listValue="emailAddress" listKey="emailId" />
我还可以遍历ArrayList userEmails
并显示值:
<s:iterator value="userEmails" var="thisEmailData">
<s:property value="emailId"/>
<s:property value="emailAddress"/>
</s:iterator>
但是emailId
当迭代ArrayList userEmails
. 我尝试了所有这些:
<s:iterator value="userEmails" var="thisEmailData">
<tr><td><s:property value="emailId"/></td></tr>
<tr><td>
<s:checkbox fieldValue="%{#emailId}" name="emailAddressesCB" theme="simple" ></s:checkbox>
<s:checkbox fieldValue="#emailId" name="emailAddressesCB" theme="simple" ></s:checkbox>
<s:checkbox fieldValue="thisEmailData.emailId" name="emailAddressesCB" theme="simple" ></s:checkbox>
<s:checkbox fieldValue="userEmails.emailId" name="emailAddressesCB" theme="simple" ></s:checkbox>
<s:checkbox fieldValue="#thisEmailData.emailId" name="emailAddressesCB" theme="simple" ></s:checkbox>
<s:checkbox fieldValue="#userEmails.emailId" name="emailAddressesCB" theme="simple" ></s:checkbox>
<s:checkbox fieldValue="%{#thisEmailData.emailId}" name="emailAddressesCB" theme="simple" ></s:checkbox>
<s:checkbox fieldValue="%{#userEmails.emailId}" name="emailAddressesCB" theme="simple" ></s:checkbox>
<s:checkbox fieldValue="emailId" name="emailAddressesCB" theme="simple" ></s:checkbox>
<s:checkbox value="%{#emailId}" name="emailAddressesCB" theme="simple" ></s:checkbox>
<s:checkbox value="#emailId" name="emailAddressesCB" theme="simple" ></s:checkbox>
<s:checkbox value="thisEmailData.emailId" name="emailAddressesCB" theme="simple" ></s:checkbox>
<s:checkbox value="userEmails.emailId" name="emailAddressesCB" theme="simple" ></s:checkbox>
<s:checkbox value="#thisEmailData.emailId" name="emailAddressesCB" theme="simple" ></s:checkbox>
<s:checkbox value="#userEmails.emailId" name="emailAddressesCB" theme="simple" ></s:checkbox>
<s:checkbox value="%{#thisEmailData.emailId}" name="emailAddressesCB" theme="simple" ></s:checkbox>
<s:checkbox value="%{#userEmails.emailId}" name="emailAddressesCB" theme="simple" ></s:checkbox>
<s:checkbox value="emailId" name="emailAddressesCB" theme="simple" >
</s:checkbox>
<s:property value="emailAddress"/>
</td></tr>
</s:iterator>
</td></tr>
</s:iterator>
从上面可以看出, value 字段永远不会填充emailId
.
我知道我缺少一些基本的东西。它是什么?