Studying Java......

          統(tǒng)計

          留言簿(1)

          積分與排名

          JavaServerFaces

          Mail Link

          Open Source

          友情鏈接

          收藏的鏈接

          閱讀排行榜

          評論排行榜

          Struts中的下拉列表標簽的使用

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

          使用時嵌套如下:
          <html:select property="ationForm.property">
              <html:option>或<html:options>或<html:optionsCollection>
          </html:select>
          其中property為ActionForm中對應的一個屬性.

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

          2..<html:options>
          <html:options collection="collection" labelProperty="displayName" property="value"/>
          其中collection為一個集合,一般是個ArrayList,displayName為前臺顯示的名稱,value為后臺實際使用的值.
          例:<html:options collection="arrayList" labelProperty="name" property="id" />

          3..<html:optionsCollection>
          <html:optionsCollection property="actionForm.property" label="displayName" value="value"/>
          其中property為ActionForm中的一個屬性,為一個集合.displayName為前臺顯示的名稱,value為后臺實際使用的值.
          例:<html:optionsCollection property="listProperty" label="name" value="id" />

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

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

          評論

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

          werewrew  回復  更多評論   

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

          非常感謝  回復  更多評論   

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

          高手
          很詳細  回復  更多評論   


          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導航:
           
          主站蜘蛛池模板: 基隆市| 蚌埠市| 永善县| 广宗县| 张家界市| 清流县| 彰化市| 德令哈市| 缙云县| 赞皇县| 克拉玛依市| 集贤县| 宜宾市| 铜梁县| 晋州市| 泾阳县| 沽源县| 玉树县| 昌都县| 阳朔县| 汨罗市| 佛冈县| 鲁山县| 上饶市| 永春县| 安康市| 浦东新区| 金川县| 武汉市| 屏东市| 英超| 岑溪市| 五莲县| 新沂市| 监利县| 三亚市| 远安县| 浦城县| 壤塘县| 新郑市| 重庆市|