我想将 FormBean 值保存在 List 中,想将其保存在 Session 中,并再次想通过 JSP 使用<logic:iterate>
. 我能够迭代列表或 FormBean 值<logic:iterate>
,但不能将两者结合起来。
我已经为此尝试过。
<table width="75%" border="0" cellspacing="1" cellpadding="0">
<logic:iterate id="myId" name="sessionData" property="getInsuredPhoneList">
<tr>
<td width="25%"> <bean:write name="myId"/> </td>
</tr>
</logic:iterate>
</table>`
显示 JSP 的动作类:
List<String> getInsuredPhoneList = new ArrayList<String>();
getInsuredPhoneList.add("");
getInsuredPhoneList.add("");
getInsuredPhoneList.add("");
getInsuredPhoneList.add("");
getInsuredPhoneList.add("");
sessionData.setGetInsuredPhoneList(getInsuredPhoneList);
处理 JSP 的动作类:
InsuredPhoneFormBean partyForm1=(InsuredPhoneFormBean)actionForm;
String type=partyForm1.getPhoneTypeCode();
String area=partyForm1.getAreaCode();
String landlineNumber=partyForm1.getLandlineNumber();
String mobileNumber=partyForm1.getMobileNumber();
String email=partyForm1.getEmailAddress();
SessionData sessionData=getSessionData(request);
List<String> getInsuredPhoneList = new ArrayList<String>();
getInsuredPhoneList.add(type);
getInsuredPhoneList.add(area);
getInsuredPhoneList.add(landlineNumber);
getInsuredPhoneList.add(mobileNumber);
getInsuredPhoneList.add(email);
sessionData.setGetInsuredPhoneList(getInsuredPhoneList);
我的输出是:
住宅 9988009988 abc@gmail.com
我想要的是getInsuredPhoneList
保存 FormBean 值的多个实例(Residential 9988009988 abc@gmail.com
,Office 9970009988 xyz@yahoo.com
),我想遍历它getInsuredPhoneList
,这样
<table>
<logic:iterate id="myId" name="sessionData" property="getInsuredPhoneList">
<tr>
<td width="25%"> <bean:write name="myId" property="abc"/> </td>
</tr>
<tr>
<td width="25%"> <bean:write name="myId" property="xyz"/> </td>
</tr>
<tr>
<td width="25%"> <bean:write name="myId" property="pqr"/> </td>
</tr>
</logic:iterate>
</table>
(property="pqr" 表示 FormBean 的属性之一)和输出如下:
Residential 9988009988 abc@gmail.com
Office 9970009988 xyz@yahoo.com