gdufo

           

          實戰Struts-Menu(1)

          2006-11-21 19:13
           一、簡介
            Struts-Menu是一組從基于XML的配置文件中生成多種樣式的菜單的JSP Tags,并且可以結合API開發通過數據庫生成的動態菜單。Struts-Menu支持國際化和多種權限控制。

          二、運行環境
            Windows 2000 Professional
            JDK 1.4.2_03
            Eclipse 3.1
            Tomcat 5.0.28
            Tomcat Plugin 3.1Beta
            Struts 1.2.7
            Commons-Lang 2.1
            Commons-Collections 3.1
            Struts-Menu 2.3
            MySQL 4.1.10a-nt

          三、下載與安裝
            1:從http://java.sun.com下載J2SDK,當前1.4.x系列的最新版本為1.4.2_08
            2:從http://www.eclipse.org下載Eclipse,當前最新版本為3.1正式版
            3:從http://jakarta.apache.org/tomcat下載Tomcat,當前5.x系列的最新版本為5.0.28
            4:從http://www.sysdeo.com/eclipse/tomcatplugin下載Eclipse的Tomcat插件,對應Eclipse3.1x的最新版本為3.1Beta
            5:從http://struts.apache.org下載Struts,當前最新版本為1.2.7
            6:從http://jakarta.apache.org/commons/下載Commons-Lang,當前最新版本為2.1,下載Commons-Collections,當前最新版本為3.1
            7:從http://struts-menu.sourceforge.net下載Struts Menu,當前最新版本為2.3
            8:從http://www.mysql.com下載MySQL數據庫,4.x系列的最新版本是4.1.12a
            9:MySQL、JDK、Eclipse、Tomcat和TomcatPlugin的安裝及配置請參考相關資料

          四、運行示例程序
            1:安裝好Tomcat后,解壓縮struts-menu-2.3.zip,將struts-menu.war釋放到Tomcat安裝目錄下的webapps下,運行Tomcat
            2:在地址欄輸入http://localhost:8080/struts-menu

          五、安裝與配置
            1:在Eclipse中新建Tomcat項目,Context為/mymenu,Subdirectory為/web
            2:在項目目錄下面新建lib目錄和web目錄及WEB-INF,在web/WEB-INF目錄下新建web.xml,內容如下:


          <?xml version="1.0" encoding="ISO-8859-1"?>

          <!DOCTYPE web-app
              PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
              "http://java.sun.com/dtd/web-app_2_3.dtd"
          >

          <web-app>
            
          <display-name>My Example Application -- Vinton Lee</display-name>
                
            
          <!-- ============= The Struts ActionServlet Configuration ============= -->
            
          <servlet>
              
          <servlet-name>action</servlet-name>
              
          <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
              
          <init-param>
                
          <param-name>config</param-name>
                
          <param-value>/WEB-INF/struts-config.xml</param-value>
              
          </init-param>
              
          <load-on-startup>1</load-on-startup>
            
          </servlet>
            
          <!-- ================================================================== -->
              
            
          <!-- ============= The Struts Action Servlet Mapping ================== -->
            
          <servlet-mapping>
              
          <servlet-name>action</servlet-name>
              
          <url-pattern>*.do</url-pattern>
            
          </servlet-mapping>
            
          <!-- ================================================================== -->
            
            
          <!-- The Welcome File List -->
            
          <welcome-file-list>
              
          <welcome-file>index.jsp</welcome-file>
            
          </welcome-file-list>

            
          <!-- =============== The Struts Taglib Definition ===================== -->
            
          <taglib>
              
          <taglib-uri>struts-bean</taglib-uri>
              
          <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
            
          </taglib>
            
          <taglib>
              
          <taglib-uri>struts-html</taglib-uri>
              
          <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
            
          </taglib>
            
          <taglib>
              
          <taglib-uri>struts-logic</taglib-uri>
              
          <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
            
          </taglib>
            
          <taglib>
              
          <taglib-uri>struts-nested</taglib-uri>
              
          <taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
            
          </taglib>
            
          <taglib>
              
          <taglib-uri>struts-tiles</taglib-uri>
              
          <taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
            
          </taglib>
            
          <!-- ================================================================== -->
            
            
          <!-- ============= The Struts-Menu Taglib Definition ================== -->
            
          <taglib>
              
          <taglib-uri>struts-menu</taglib-uri>
              
          <taglib-location>/WEB-INF/struts-menu.tld</taglib-location>
            
          </taglib>
            
          <!-- ================================================================== -->
          </web-app>

          3:解壓縮struts-1.2.7.zip,將壓縮包中的lib目錄下所有的8個jar釋放到lib目錄中,將5個tld文件釋放到web\WEB-INF目錄中,在web\WEB-INF目錄中新建struts-config.xml,內容如下:

          <?xml version="1.0" encoding="ISO-8859-1" ?>

          <!DOCTYPE struts-config PUBLIC
                    "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
                    "http://struts.apache.org/dtds/struts-config_1_2.dtd"
          >

          <struts-config>

              
          <!-- ========== Data Source Configuration =============================== -->
              
          <data-sources />

              
          <!-- ========== Form Bean Definitions =================================== -->
              
          <form-beans />

              
          <!-- ========== Global Exception Definitions ============================ -->
              
          <global-exceptions />

              
          <!-- ========== Global Forward Definitions ============================== -->
              
          <global-forwards />

              
          <!-- ========== Action Mapping Definitions ============================== -->
              
          <action-mappings />

              
          <!-- ========== Controller Configuration ================================ -->

              
          <!-- ========== Message Resources Definitions =========================== -->
              
          <message-resources parameter="application" />

              
          <!-- ========== Plug Ins Configuration ================================== -->
              
          <plug-in className="net.sf.navigator.menu.MenuPlugIn">
                
          <set-property property="menuConfig" value="/WEB-INF/menu-config.xml"/>
              
          </plug-in>

          </struts-config>

          posted on 2008-08-05 14:52 gdufo 閱讀(259) 評論(0)  編輯  收藏 所屬分類: Struts2

          導航

          統計

          常用鏈接

          留言簿(6)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          收藏夾

          Hibernate

          友情鏈接

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 卓资县| 长沙县| 马公市| 双城市| 衡东县| 肃宁县| 唐山市| 准格尔旗| 荣昌县| 高密市| 旌德县| 丰镇市| 丰宁| 芜湖市| 乌审旗| 揭西县| 旌德县| 盐亭县| 沭阳县| 广安市| 乐亭县| 桦南县| 南澳县| 顺义区| 新巴尔虎左旗| 焦作市| 聂荣县| 灵寿县| 兴和县| 辽阳县| 鸡东县| 霍州市| 隆尧县| 琼中| 松桃| 邹平县| 闵行区| 长治市| 扎囊县| 衡南县| 陵水|