解析Struts配置教程_JSP教程

      編輯Tag賺U幣
      教程Tag:暫無Tag,歡迎添加,賺取U幣!

      推薦:解析簡單計數器的并發問題
      %@pagelanguage=javacontentType=text/html;charset=UTF-8 pageEncoding=UTF-8% EhtmlPUBLIC-//W3C//DTDHTML4.01TR/html4/loose.dtd html head metahttp-equiv=Content-Typecontent=text/html;charse

        Struts框架是目前流行的JSP開發框架,本文就其進行了基礎講解。
           
      首先下載Struts軟件包,到 http://struts.apache.org/下載Struts,Struts各版本的差異很大,這里已Struts1.2.9版本為例,解壓縮包內容如下:   
        1、在tomcat安裝目錄下的webapps目錄中建立一個webjx目錄。這樣就可以通過訪問"http://localhost:8080/webjx"訪問"webjx"這個目錄。 
        2、在你創建的目錄webjx中,建立WEB-INF目錄,在WEB-INF中建立classes、lib和tld文件夾。將壓縮包struts-1.2.9-bin\lib文件夾中的 commons-*.jar(*代表任意位任意字符)和struts.jar文件拷貝到建立的 webjx/WEB-INF/lib目錄下,然后將Struts中的標簽庫文件 struts-*.tld(*代表任意位任意字符)拷貝到 webjx/WEB-INF/tld目錄下 
        3、在webjx/WEB-INF/目錄下建立一個web.xml文件,文件內容如下: 
      <?xml version="1.0" encoding="ISO-8859-1"?>  
      <!DOCTYPE web-app  
        PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"  
        "http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">  
      <web-app>  
        <display-name>Struts Blank Application</display-name>  
        <!-- Standard Action Servlet Configuration (with debugging) -->  
        <servlet>  
          <servlet-name>action</servlet-name>  
          <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>  
          <init-param>  
            <param-name>application</param-name>  
            <param-value>ApplicationResources</param-value>  
          </init-param>  
          <init-param>  
            <param-name>config</param-name>  
            <param-value>/WEB-INF/struts-config.xml</param-value>  
          </init-param>  
          <init-param>  
            <param-name>debug</param-name>  
            <param-value>2</param-value>  
          </init-param>  
          <init-param>  
            <param-name>detail</param-name>  
            <param-value>2</param-value>  
          </init-param>  
          <load-on-startup>2</load-on-startup>  
        </servlet>  
        <!-- Standard Action Servlet Mapping -->  
        <servlet-mapping>  
          <servlet-name>action</servlet-name>  
          <url-pattern>*.do</url-pattern>  
        </servlet-mapping>  
        <!-- The Usual Welcome File List -->  
        <welcome-file-list>  
          <welcome-file>index.jsp</welcome-file>  
        </welcome-file-list>  
        <!-- Struts Tag Library Descriptors -->  
        <taglib>  
          <taglib-uri>/tags/struts-bean</taglib-uri>  
          <taglib-location>/WEB-INF/tld/struts-bean.tld</taglib-location>  
        </taglib> 
        <taglib>  
          <taglib-uri>/tags/struts-html</taglib-uri>  
          <taglib-location>/WEB-INF/tld/struts-html.tld</taglib-location>  
        </taglib> 
        <taglib>  
          <taglib-uri>/tags/struts-logic</taglib-uri>  
          <taglib-location>/WEB-INF/tld/struts-logic.tld</taglib-location>  
        </taglib> 
        <taglib>  
          <taglib-uri>/tags/struts-nested</taglib-uri>  
          <taglib-location>/WEB-INF/tld/struts-nested.tld</taglib-location>  
        </taglib> 
        <taglib>  
          <taglib-uri>/tags/struts-tiles</taglib-uri>  
          <taglib-location>/WEB-INF/tld/struts-tiles.tld</taglib-location>  
        </taglib> 
      </web-app> 

      4、在webjx/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://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">  
      <struts-config>  
          <form-beans>  
          </form-beans>  
          <global-forwards>  
          </global-forwards>  
          <action-mappings>  
          </action-mappings>  
          <message-resources parameter="ApplicationResources"/>  
      </struts-config> 

      分享:struts+spring實現的登陸實例源碼
      剛接觸Jsp的struts不久,又要學spring,然后把兩者結合起來用。于是我在網上找了很多的有關struts+spring的例子,但基本上都是a的例子,然后根據它的原理重新編寫一本書上用struts實現的例子。 一、運行環境 1、eclipse-SDK-3.2 2、MyEclipseGA5.0 3、apache-

      共2頁上一頁12下一頁
      來源:模板無憂//所屬分類:JSP教程/更新時間:2010-03-15
      相關JSP教程