struts2 combobox - 通过表单向行动传递整数id而不是String name

时间:2009-03-26 20:30:45

标签: forms combobox struts2 action

我的表单是将国家/地区的字符串名称传递给操作。我怎样才能将对象国家的ID从组合框传递到动作?

这就是我所拥有的:

s:combobox label =“Country”name =“country”headerValue =“Select”headerKey =“1”list =“%{countries}”listValue =“name”/>

感谢。

1 个答案:

答案 0 :(得分:1)

您错过了 listKey 属性。 如果您将其更改为:

<s:combobox label="Country" name="country" headerValue="Select" headerKey="1"
list="%{countries}" listValue="name" listKey="id"/>

它可能会奏效。

有关所有可用属性,请参阅http://struts.apache.org/2.0.14/docs/combobox.html