使用相同的struts html:optionsCollection进行差异下拉

时间:2013-04-24 06:22:04

标签: java struts

我正在使用struts 1.1,我有两个具有相同数据的下拉列表(下拉列表)。我必须将选定的两个值保存为两个不同列中的varchars 我可以使用表格中为同一个下拉菜单创建的相同地图来完成此操作吗?

例如下面是一个下拉列表,它保存了用户ID,并假设还有另一个类似的下拉列表,我保存了创建用户ID,它们都使用相同的填充用户列表。

<html:select property="selectedCancelUserId">
     <html:option value="">-</html:option>
     <html:optionsCollection property="usedByUserList" label="name" value="staffNo"/>
</html:select>

1 个答案:

答案 0 :(得分:0)

您需要在表单中使用两个不同的表单变量,如selectedCancelUserIdselectedCreateUserId,以捕获用户的两个不同输入。只要您将表单值与表单值相关联,usedByUserList就可以在表单中多次使用。

 <html:select property="selectedCancelUserId">
       <html:option value="">-</html:option>
       <html:optionsCollection property="usedByUserList" label="name" value="staffNo"/>
 </html:select>

 <html:select property="selectedCreateUserId">
       <html:option value="">-</html:option>
       <html:optionsCollection property="usedByUserList" label="name" value="staffNo"/>
 </html:select>