html:select 使用
最近使用<html:select>標(biāo)簽,下面是我的一點(diǎn)體會(huì):
1. <html:select> 標(biāo)簽一點(diǎn)要嵌套在 <html:form> 標(biāo)簽中使用
2. 必須設(shè)置<html:select>的property屬性,并且屬性的名字要和 YourActionForm 中數(shù)據(jù)成員名相同,且提供getXXX() 和 setXXX() 方法. 提交表單后 property 屬性中存放的就是用戶的選擇項(xiàng)
3. 下拉框用的是鍵/值對(duì)的模式,因此建議把數(shù)據(jù)存放在 LabelValueBean 對(duì)象中,并把這些對(duì)象存放在List中,也方便后續(xù)運(yùn)用;
4. 在<html:select>標(biāo)簽中運(yùn)用<html:options>來顯示數(shù)據(jù)
<html:option collection="存放對(duì)象的List"
property="value" 對(duì)應(yīng)值
LabelProperty="label" 對(duì)應(yīng)鍵/>
5. 這樣就可以在頁面中顯示下拉框了
1. <html:select> 標(biāo)簽一點(diǎn)要嵌套在 <html:form> 標(biāo)簽中使用
2. 必須設(shè)置<html:select>的property屬性,并且屬性的名字要和 YourActionForm 中數(shù)據(jù)成員名相同,且提供getXXX() 和 setXXX() 方法. 提交表單后 property 屬性中存放的就是用戶的選擇項(xiàng)
3. 下拉框用的是鍵/值對(duì)的模式,因此建議把數(shù)據(jù)存放在 LabelValueBean 對(duì)象中,并把這些對(duì)象存放在List中,也方便后續(xù)運(yùn)用;
4. 在<html:select>標(biāo)簽中運(yùn)用<html:options>來顯示數(shù)據(jù)
<html:option collection="存放對(duì)象的List"
property="value" 對(duì)應(yīng)值
LabelProperty="label" 對(duì)應(yīng)鍵/>
5. 這樣就可以在頁面中顯示下拉框了
posted on 2007-06-21 00:09 lqx 閱讀(3042) 評(píng)論(0) 編輯 收藏