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