tosoft's blog
          j2se,j2ee,j2me,opensource,框架
          posts - 1,comments - 2,trackbacks - 0
              struts的 <html:option>有三種選項(xiàng)模式,由于最近學(xué)習(xí)用struts做項(xiàng)目,需要解決下拉列表從數(shù)據(jù)庫讀值的問題,在網(wǎng)絡(luò)上搜索了很久,終于弄清楚了,現(xiàn)總結(jié)一下,并且給出例子。

          一、FormBean

                  private List<LabelValueBean> beanCollection;
                  .....        ......
                  get(),set()方法。

          二、Action

                  .....從數(shù)據(jù)庫得到返回的List 并將返回的List對象轉(zhuǎn)換成Iterator類型 遍歷
                       
                  beanCollection.add(new LabelValueBean(“前臺顯示名稱”,“實(shí)際值”);

                  setBeanCollection(beanCollection);

          三、JSP頁面

                  <html:select property="select" onchange="form.submit();">
                          <html:optionsCollection name="form名稱" property="beanCollection" />
                 </html:select>

          這樣就解決了。。。
          posted on 2008-02-07 23:49 tosoft 閱讀(811) 評論(2)  編輯  收藏

          FeedBack:
          # re: 解決struts下拉菜單選項(xiàng)從數(shù)據(jù)庫讀值的問題
          2008-10-26 21:33 |
          簡潔明了  回復(fù)  更多評論
            
          # re: 解決struts下拉菜單選項(xiàng)從數(shù)據(jù)庫讀值的問題[未登錄]
          2008-10-26 21:37 | xxx
          @比
          ......<html>
          <script>
          alert("fdsfdsafdsa")
          </script>
          <body>


          </body>

          </html>  回復(fù)  更多評論
            

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


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 和林格尔县| 玉环县| 巨鹿县| 阳江市| 深泽县| 宣武区| 武山县| 清远市| 尼木县| 庆安县| 东莞市| 塘沽区| 文登市| 叙永县| 酒泉市| 桓仁| 深泽县| 平湖市| 黄石市| 东海县| 镇江市| 房产| 通化市| 嘉荫县| 唐河县| 盘锦市| 北票市| 张掖市| 仲巴县| 南昌市| 友谊县| 西昌市| 南康市| 德令哈市| 都兰县| 新昌县| 岳阳市| 陵水| 松阳县| 玉山县| 从化市|