场景:
在使用Spring+Struts2+iBatis框架的时候,
有一个添加的表单,里面有text字段,有radio,也有select,添加成功后,显示到列表页面中。
如果我们要进行更新,我们根据字段的主键进行查询得到数据库中的记录,然后将记录显示到更新的页面中去,那么我们就要知道radio,select,checkbox数据库中保存的值是什么?
使用foreach的做法是,
1.action中创建Map集合,保存下拉框中的值,然后传到页面中。
2.<select name="configContrastTemlet.config.type">
<c:foreach items="${configTypes}" var="configType">
<option value="${configType.key}"
<c:if test="${configType.key eq configContrastTemlet.configType}" >selected</c:if>>
${configType.value}
</option>
</c:foreach>
</select>
场景2:
在使用Spring+Hibernate+Struts2框架的时候,
<s:select id="receiverFlag" name="InternalMessageDTO.receiverFlag"
list="#request.receiversFlag" listKey="key" listValue="value"
cssClass="formSelect" theme="simple" />
其中list中的值是通过request对象传递过来的“Map”集合,key和value是optionInteger对象的成员变量。
<s:radio name="storeInfoDTO.mainProduct" id="mainProduct"
list="#request.mainProductValue" listKey="key" listValue="value"
theme="simple" />