<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    云下的天空

    堅持 隨心而動 走自己的路

     

    Tomcat中web.xml文件的詳細說明

    原文轉自:

    http://blog.csdn.net/pathfinder163/archive/2009/09/02/4506817.aspx


    <?xml version="1.0" encoding="GB2312"?> <!-- 
    Web.xml依次定議了如下元素: 
    <web-app> 

    <display-name></display-name> 定義了WEB應用的名字 

    <description></description> 聲明WEB應用的描述信息 

    <filter></filter> 

    <filter-mapping></filter-mapping>
     

    <servlet></servlet> 

    <servlet-mapping></servlet-mapping> 

    <session-config></session-config> 

    <welcome-file-list></welcome-file-list> 

    <taglib></taglib> 

    <resource-ref></resource-ref> 

    <security-constraint></security-constraint> 

    <login-config></login-config> 

    </web-app> 
    在web.xml中元素定義的先后順序不能顛倒,否則Tomcat服務器可能會拋出SAXParseException. 
    --> 
    <!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>Sample Application</display-name>

    <description> 
    This is a Sample Application 
    </description>

    <!-- 
    filter 配置Servlet過濾器 
    filter-name 定義過濾器的名字。當有多個過濾器時,不能同名 
    filter-class 指定實現這一過濾的類,這個類負責具體的過濾事務 
    --> 
    <filter> 
    <filter-name>SampleFilter</filter-name> 
    <filter-class>mypack.SampleFilter</filter-class> 
    </filter>

    <!-- 
    filter-mapping 設定過濾器負責過濾的URL 
    filter-name 過濾器名。這里的名字一定要和filter中的過濾器名匹配 
    url-pattern 指定過濾器負責過濾的URL 
    --> 
    <filter-mapping> 
    <filter-name>SampleFilter</filter-name> 
    <url-pattern>*.jsp</url-pattern> 
    </filter-mapping>

    <!-- 
    servlet 配置Servlet. 
    servlet-name 定義Servlet的名字 
    servlet-class 指定實現這個servlet的類 
    init-param 定義Servlet的初始化參數和參數值,可有多個init-param。在servlet類中通過getInitParamenter(String name)方法訪問初始化參數 
    load-on-startup 指定當Web應用啟動時,裝載Servlet的次序。 
    當值為正數或零時:Servlet容器先加載數值小的servlet,再依次加載其他數值大的servlet. 
    當值為負或未定義:Servlet容器將在Web客戶首次訪問這個servlet時加載它 
    --> 
    <servlet> 
    <servlet-name>SampleServlet</servlet-name> 
    <servlet-class>mypack.SampleServlet</servlet-class> 
    <init-param> 
    <param-name>initParam1</param-name> 
    <param-value>2</param-value> 
    </init-param> 
    <load-on-startup>1</load-on-startup> 
    </servlet>

    <!-- 
    配置servlet映射(下面代碼為SampleServlet指定的相對URL為"/sample": 
    servlet-name 指定servlet的名字,這里的名字應該和<Servlet>元素中定義的名字匹配。 
    url-pattern 指定訪問這個servlet的URL。只需給出相對路徑。 
    --> 
    <servlet-mapping> 
    <servlet-name>SampleServlet</servlet-name> 
    <url-pattern>/sample</url-pattern> 
    </servlet-mapping>

    <!--配置session session用來設定HttpSession的生命周期。單位(秒)--> 
    <session-config> 
    <session-timeout>30</session-timeout> 
    </session-config>

    <!--配置Wel0come0文件清單--> 
    <welcome-file-list> 
    <welcome-file>login.jsp</welcome-file> 
    <welcome-file>index.htm</welcome-file> 
    </welcome-file-list>

    <!-- 
    配置Tag Library 
    taglib-uri 設定Tag Library的唯一標識符,在Web應用中將根據這一標識符來引用Tag Library 
    taglib-location 指定和Tag Library對應的TLD文件的位置 
    --> 
    <taglib> 
    <taglib-uri>/mytaglib</taglib-uri> 
    <taglib-location>/WEB-INF/mytaglib.tld</taglib-location> 
    </taglib>

    <!-- 
    配置資源引用 
    description 對所引用的資源的說明 
    res-ref-name 指定所引用資源的JNDI名字 
    res-type 指定所引用資源的類名字 
    res-auth 指定管理所引用資源的Manager,它有兩個可選值: 
    Container:由容器來創建和管理resource 
    Application:同WEB應用來創建和管理Resource 
    --> 
    <resource-ref> 
    <description>DB Connection</description> 
    <res-ref-name>jdbc/sampleDB</res-ref-name> 
    <res-type>javax.sql.DataSource</res-type> 
    <res-auth>Container</res-auth> 
    </resource-ref>

    <!-- 
    配置安全約束(以下代碼指定當用戶訪問該WEB應用下的所有資源時,必須具備guest角色) 
    web-resource-collection 聲明受保護的WEB資源 
    auth-constraint 聲明可以訪問受保護資源的角色,可以包含多個<role-name>子元素

    web-resource-name 標識受保護的WEB資源 
    url-pattern 指定受保護的URL路徑 
    --> 
    <Security-constraint> 
    <web-resource-collection> 
    <web-resource-name>sample appliction</web-resource-name> 
    <url-pattern>/*</url-pattern> 
    </web-resource-collection> 
    <auth-constraint> 
    <role-name>guest</role-name> 
    </auth-constraint> 
    </Security-constraint>


    <!-- 
    配置安全驗證登錄界面:指定當WEB客戶訪問受保護的WEB資源時,系統彈出的登錄對話框的類型。 
    auth-method 指定驗證方法,它有三個可選值:BASIC(基本驗證)、DIGEST(摘要驗證)、FORM(表單驗證) 
    realm-name 設定安全域的名稱 
    form-login-config 當驗證方法為FORM時,配置驗證網頁和出錯網頁 
    form-login-page 當驗證方法為FORM時,設定驗證網頁 
    form-error-page 當驗證方法為FORM時,設定出錯網頁 
    --> 
    <login-config> 
    <auth-method>FORM</auth-method> 
    <realm-name> 
    Tomcat Server Configuration form-Based Authentication Area 
    </realm-name> 
    <form-login-config> 
    <form-login-page>/login.jsp</form-login-page> 
    <form-error-page>/error.jsp</form-error-page> 
    </form-login-config> 
    </login-config>

    <!--配置對安全驗證角色的引用--> 
    <security-role> 
    <description> 
    The role that is required to log into the sample application 
    </description> 
    <role-name>guest</role-name> 
    </security-role> 

    </web-app>

    <?xml version="1.0" encoding="GB2312"?> <!-- 
    Web.xml依次定議了如下元素: 
    <web-app> 
    <display-name></display-name> 定義了WEB應用的名字 
    <description></description> 聲明WEB應用的描述信息 
    <filter></filter> 
    <filter-mapping></filter-mapping> 
    <servlet></servlet> 
    <servlet-mapping></servlet-mapping> 
    <session-config></session-config> 
    <welcome-file-list></welcome-file-list> 
    <taglib></taglib> 
    <resource-ref></resource-ref> 
    <security-constraint></security-constraint> 
    <login-config></login-config> 
    </web-app> 
    在web.xml中元素定義的先后順序不能顛倒,否則Tomcat服務器可能會拋出SAXParseException. 
    --> 
    <!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>Sample Application</display-name>

    <description> 
    This is a Sample Application 
    </description>

    <!-- 
    filter 配置Servlet過濾器 
    filter-name 定義過濾器的名字。當有多個過濾器時,不能同名 
    filter-class 指定實現這一過濾的類,這個類負責具體的過濾事務 
    --> 
    <filter> 
    <filter-name>SampleFilter</filter-name> 
    <filter-class>mypack.SampleFilter</filter-class> 
    </filter>

    <!-- 
    filter-mapping 設定過濾器負責過濾的URL 
    filter-name 過濾器名。這里的名字一定要和filter中的過濾器名匹配 
    url-pattern 指定過濾器負責過濾的URL 
    --> 
    <filter-mapping> 
    <filter-name>SampleFilter</filter-name> 
    <url-pattern>*.jsp</url-pattern> 
    </filter-mapping>

    <!-- 
    servlet 配置Servlet. 
    servlet-name 定義Servlet的名字 
    servlet-class 指定實現這個servlet的類 
    init-param 定義Servlet的初始化參數和參數值,可有多個init-param。在servlet類中通過getInitParamenter(String name)方法訪問初始化參數 
    load-on-startup 指定當Web應用啟動時,裝載Servlet的次序。 
    當值為正數或零時:Servlet容器先加載數值小的servlet,再依次加載其他數值大的servlet. 
    當值為負或未定義:Servlet容器將在Web客戶首次訪問這個servlet時加載它 
    --> 
    <servlet> 
    <servlet-name>SampleServlet</servlet-name> 
    <servlet-class>mypack.SampleServlet</servlet-class> 
    <init-param> 
    <param-name>initParam1</param-name> 
    <param-value>2</param-value> 
    </init-param> 
    <load-on-startup>1</load-on-startup> 
    </servlet>

    <!-- 
    配置servlet映射(下面代碼為SampleServlet指定的相對URL為"/sample": 
    servlet-name 指定servlet的名字,這里的名字應該和<Servlet>元素中定義的名字匹配。 
    url-pattern 指定訪問這個servlet的URL。只需給出相對路徑。 
    --> 
    <servlet-mapping> 
    <servlet-name>SampleServlet</servlet-name> 
    <url-pattern>/sample</url-pattern> 
    </servlet-mapping>

    <!--配置session session用來設定HttpSession的生命周期。單位(秒)--> 
    <session-config> 
    <session-timeout>30</session-timeout> 
    </session-config>

    <!--配置Wel0come0文件清單--> 
    <welcome-file-list> 
    <welcome-file>login.jsp</welcome-file> 
    <welcome-file>index.htm</welcome-file> 
    </welcome-file-list>

    <!-- 
    配置Tag Library 
    taglib-uri 設定Tag Library的唯一標識符,在Web應用中將根據這一標識符來引用Tag Library 
    taglib-location 指定和Tag Library對應的TLD文件的位置 
    --> 
    <taglib> 
    <taglib-uri>/mytaglib</taglib-uri> 
    <taglib-location>/WEB-INF/mytaglib.tld</taglib-location> 
    </taglib>

    <!-- 
    配置資源引用 
    description 對所引用的資源的說明 
    res-ref-name 指定所引用資源的JNDI名字 
    res-type 指定所引用資源的類名字 
    res-auth 指定管理所引用資源的Manager,它有兩個可選值: 
    Container:由容器來創建和管理resource 
    Application:同WEB應用來創建和管理Resource 
    --> 
    <resource-ref> 
    <description>DB Connection</description> 
    <res-ref-name>jdbc/sampleDB</res-ref-name> 
    <res-type>javax.sql.DataSource</res-type> 
    <res-auth>Container</res-auth> 
    </resource-ref>

    <!-- 
    配置安全約束(以下代碼指定當用戶訪問該WEB應用下的所有資源時,必須具備guest角色) 
    web-resource-collection 聲明受保護的WEB資源 
    auth-constraint 聲明可以訪問受保護資源的角色,可以包含多個<role-name>子元素

    web-resource-name 標識受保護的WEB資源 
    url-pattern 指定受保護的URL路徑 
    --> 
    <Security-constraint> 
    <web-resource-collection> 
    <web-resource-name>sample appliction</web-resource-name> 
    <url-pattern>/*</url-pattern> 
    </web-resource-collection> 
    <auth-constraint> 
    <role-name>guest</role-name> 
    </auth-constraint> 
    </Security-constraint>


    <!-- 
    配置安全驗證登錄界面:指定當WEB客戶訪問受保護的WEB資源時,系統彈出的登錄對話框的類型。 
    auth-method 指定驗證方法,它有三個可選值:BASIC(基本驗證)、DIGEST(摘要驗證)、FORM(表單驗證) 
    realm-name 設定安全域的名稱 
    form-login-config 當驗證方法為FORM時,配置驗證網頁和出錯網頁 
    form-login-page 當驗證方法為FORM時,設定驗證網頁 
    form-error-page 當驗證方法為FORM時,設定出錯網頁 
    --> 
    <login-config> 
    <auth-method>FORM</auth-method> 
    <realm-name> 
    Tomcat Server Configuration form-Based Authentication Area 
    </realm-name> 
    <form-login-config> 
    <form-login-page>/login.jsp</form-login-page> 
    <form-error-page>/error.jsp</form-error-page> 
    </form-login-config> 
    </login-config>

    <!--配置對安全驗證角色的引用--> 
    <security-role> 
    <description> 
    The role that is required to log into the sample application 
    </description> 
    <role-name>guest</role-name> 
    </security-role> 
    </web-app>

    posted on 2011-06-02 17:19 天空布藍 閱讀(875) 評論(0)  編輯  收藏 所屬分類: JAVA EE


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


    網站導航:
     

    導航

    統計

    常用鏈接

    留言簿

    隨筆分類

    隨筆檔案

    Flex學習鏈接

    搜索

    •  

    最新評論

    • 1.?re: tomcat7的配置
    • 新建變量名: TOMCAT_HOME 應該為CATALINA_HOME
    • --houkai
    • 2.?re: tomcat7的配置
    • 確實是的@寒澈
    • --houkai
    • 3.?re: tomcat7的配置
    • @ftp123
      你娘里個大雪碧 里面會有common這個文件夾嗎 不知道還尼瑪在這瞎比比 純尼瑪誤導人 我最惡心的就是這樣沒事裝逼的人 艸
    • --cao
    • 4.?re: tomcat7的配置
    • 從哪抄來的,是抄的,你也說聲啊,要不自己測試下也可以,害人測試半天。
    • --ftp123
    • 5.?re: tomcat7的配置
    • %TOMCAT_HOME%\common\lib 從tomcat6.0開始已經沒有common文件夾了,直接用\lib,害我找了半天common文件夾啊,趕快改過來吧
    • --寒澈

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 久久亚洲精品中文字幕三区| 亚洲a级在线观看| 久久精品一本到99热免费| 久久乐国产综合亚洲精品| 久久久久国产亚洲AV麻豆| 亚洲精品在线免费观看| 老妇激情毛片免费| 亚洲经典在线中文字幕| 亚洲成a人一区二区三区| 99精品国产成人a∨免费看| 苍井空亚洲精品AA片在线播放 | 免费污视频在线观看| 亚洲一区二区三区高清在线观看 | 自拍日韩亚洲一区在线| 亚洲午夜福利在线观看| 免费可以看黄的视频s色| 黄色视频在线免费观看| 亚洲中文字幕无码中文| 亚洲成色在线综合网站 | 91亚洲va在线天线va天堂va国产| 国产精品自在自线免费观看 | 亚洲欧洲日产国码高潮αv| 毛片免费全部播放无码| 国产日韩在线视频免费播放| 亚洲日本va一区二区三区| 亚洲五月六月丁香激情| 国产专区一va亚洲v天堂| 最近中文字幕免费mv视频8| 人妻无码久久一区二区三区免费| 一级做a爰片性色毛片免费网站| 亚洲天堂电影在线观看| 久久亚洲综合色一区二区三区| 亚洲成网777777国产精品| 成人看的午夜免费毛片| 67pao强力打造国产免费| 久久精品免费网站网| 美女扒开屁股让男人桶爽免费| 亚洲午夜一区二区三区| 亚洲黄色在线观看| 久久亚洲精品AB无码播放| 激情97综合亚洲色婷婷五|