Studying Java......

          統(tǒng)計(jì)

          留言簿(1)

          積分與排名

          JavaServerFaces

          Mail Link

          Open Source

          友情鏈接

          收藏的鏈接

          閱讀排行榜

          評(píng)論排行榜

          Struts中的下拉列表標(biāo)簽的使用

          頁(yè)面中經(jīng)常用到下拉列表,下面是個(gè)人對(duì)于STRUTS中標(biāo)簽使用的一點(diǎn)總結(jié):
          STRUTS中的下拉選擇列表標(biāo)簽必須嵌套在<html:form>標(biāo)簽中,包括:
          1.<html:select>
          2.<html:option>
          3.<html:options>
          4.<html:optionsCollection>

          使用時(shí)嵌套如下:
          <html:select property="ationForm.property">
              <html:option>或<html:options>或<html:optionsCollection>
          </html:select>
          其中property為ActionForm中對(duì)應(yīng)的一個(gè)屬性.

          1.<html:option>
          <html:option value="value">displayName</html:option>
          其中value為實(shí)際使用的值(賦值到ActionForm對(duì)應(yīng)的屬性中) displayName頁(yè)面中顯示的信息.
          例:<html:option value=""></html:option>顯示一個(gè)空白選擇,值為"".

          2..<html:options>
          <html:options collection="collection" labelProperty="displayName" property="value"/>
          其中collection為一個(gè)集合,一般是個(gè)ArrayList,displayName為前臺(tái)顯示的名稱(chēng),value為后臺(tái)實(shí)際使用的值.
          例:<html:options collection="arrayList" labelProperty="name" property="id" />

          3..<html:optionsCollection>
          <html:optionsCollection property="actionForm.property" label="displayName" value="value"/>
          其中property為ActionForm中的一個(gè)屬性,為一個(gè)集合.displayName為前臺(tái)顯示的名稱(chēng),value為后臺(tái)實(shí)際使用的值.
          例:<html:optionsCollection property="listProperty" label="name" value="id" />

          補(bǔ)充一點(diǎn):如果要從 數(shù)據(jù)庫(kù)去取數(shù)據(jù),一般是在 action 里調(diào)用 DAO ,把結(jié)果存入一個(gè)ArrayList作為 request 的一個(gè)屬性傳到頁(yè)面上; 這時(shí)一般用 <html:options .../> 標(biāo)簽.另外,如果數(shù)據(jù)不從數(shù)據(jù)庫(kù)去取,而是代碼固定的,則一般把這種放到 ActionForm 里,作為屬性在頁(yè)面上取,這時(shí)一般用 <html:optionsCollection ... /> .

          posted on 2005-11-24 10:21 Terence 閱讀(2681) 評(píng)論(3)  編輯  收藏 所屬分類(lèi): STRUTS

          評(píng)論

          # re: Struts中的下拉列表標(biāo)簽的使用 2006-08-22 11:57 阿瑟大

          werewrew  回復(fù)  更多評(píng)論   

          # re: Struts中的下拉列表標(biāo)簽的使用 2006-09-26 15:59 文子

          非常感謝  回復(fù)  更多評(píng)論   

          # re: Struts中的下拉列表標(biāo)簽的使用 2006-09-26 15:59 文子

          高手
          很詳細(xì)  回復(fù)  更多評(píng)論   


          只有注冊(cè)用戶(hù)登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 马关县| 广丰县| 太谷县| 江孜县| 星子县| 天气| 花莲县| 乌拉特中旗| 繁昌县| 明溪县| 鄄城县| 九江市| 长宁区| 阿克陶县| 峨边| 犍为县| 巴林右旗| 呼图壁县| 道孚县| 利津县| 丰原市| 施秉县| 铁岭县| 榕江县| 翼城县| 天长市| 九龙县| 肥乡县| 三明市| 高要市| 南投市| 邮箱| 大田县| 禹城市| 资阳市| 灵台县| 容城县| 库车县| 宜良县| 稻城县| 铅山县|