雅典之夏的小站
          知人者智 自知者明 Fighting!!

          在jsp輕易實現下拉菜單,那么在struts中呢?
          大概的步驟如下:
          1首先定義一個bean,最少有兩個屬性,每個屬性都有set和get的方法
          2定義一個業務邏輯類,重復從數據庫中讀取紀錄為Bean賦值,將這些bean添加入一個Collection
          3將collection放入到Request中。
          4在JSP中用的標簽顯示出來
          實例:
          要實現一個顯示姓名返回Id值 的下拉菜單,
          1首先實現一個user的bean,該bean有兩個屬性,name,id,每個屬性都有對應set和get的方法
          比如name就有,setname()和getname()的方法
          2定義一個邏輯類,GetUserList
          ?????????select * from User;
          ???????? Collection listuser;
          ???????????????while(rs.next()){
          ?????????????????????????user.setname(rs.getString(username));
          ???????????????????????????....
          ????????????????????????listuser.add(user);
          }
          3比如list.jsp做為要顯示下拉菜單的頁面,那么在/list 對應的action ListUser中應該
          request.setAttribute("userlist",user);
          4,在list.jsp中用
          //actionForm中定義的變量
          ???

          即可
          不過這樣顯示的只是簡單的菜單,要實現能動態得跳轉得不知道用什么辦法

          posted on 2005-10-27 16:51 rkind 閱讀(1132) 評論(2)  編輯  收藏 所屬分類: Struts

          FeedBack:
          # re: Struts中下拉菜單的實現[原創]
          2007-01-30 16:02 | import javax.servlet.http.HttpServletRequest;
          import javax.servlet.http.HttpServletRequest;
          import javax.servlet.http.HttpServletResponse;
          import org.apache.struts.action.Action;
          import org.apache.struts.action.ActionForm;
          import org.apache.struts.action.ActionForward;
          import org.apache.struts.action.ActionMapping;
          import com.books.struts.form.IssuebookForm;

          import org.springframework.context.ApplicationContext;
          import org.springframework.context.support.ClassPathXmlApplicationContext;
          import com.books.maps.LackBooklist;
          import com.books.maps.LackBooklistDAO;


          import org.hibernate.SessionFactory;
          import org.springframework.orm.*;  回復  更多評論
            
          # re: Struts中下拉菜單的實現[原創]
          2007-07-11 11:11 | hf
          henhao  回復  更多評論
            
          主站蜘蛛池模板: 永泰县| 包头市| 长宁县| 襄垣县| 万盛区| 成都市| 鲁甸县| 奎屯市| 宁海县| 亳州市| 武城县| 万全县| 满城县| 榕江县| 吉隆县| 大余县| 平山县| 茌平县| 高青县| 清水县| 马山县| 沙河市| 开封县| 江北区| 鸡西市| 安乡县| 甘肃省| 昌平区| 新巴尔虎右旗| 桑植县| 自贡市| 塘沽区| 天祝| 松阳县| 乐平市| 新泰市| 诏安县| 岢岚县| 军事| 清远市| 武城县|