2011-08-23 47 views
0

在JSP中使用<html:options>動態加載下拉列表時,如何默認選擇一個選項?處理<html:options>

這裏是我的代碼:

<html:select property="menu" > 
    <html:option value="">–SELECT–</html:option> 
    <html:options collection="menuList" property="value" labelProperty="label" /> 
</html:select> 
+0

您在那裏使用的不僅僅是JSP。 –

回答

0

您可以指定所選擇的項目是這樣的:

<html:select property="selectedItem"> 

所有你在你的動作做的是調用setSelectedItem(「myselection」)從您的表單對象。

我假設你在這裏使用Struts。