将动态值设置为html:select标记的“value”属性

时间:2011-12-24 08:06:45

标签: struts struts-1

如何为value中的Struts html:select标记的bean:write属性设置动态值以突出显示所选内容?

1 个答案:

答案 0 :(得分:0)

html select标签会自动选择值等于select标签属性的选项。因此,如果您的表单bean具有getFoo()方法并且此方法返回“bar”,则以下select标签将选择值为“bar”的选项:

<html:select property="foo">
    list of options
</html:select>

要选择某个选项,只需将其值放在表单bean的属性中:

// in the action
form.setFoo("bar");

// in the JSP
<html:select property="foo">
    list of options
</html:select>
相关问题