<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # Tomcat – 啟用/禁用目錄列表 > 原文: [https://howtodoinjava.com/tomcat/tomcat-enabledisable-directory-listing/](https://howtodoinjava.com/tomcat/tomcat-enabledisable-directory-listing/) 當您的應用部署在 **tomcat** Web 服務器中,并且您請求指向目錄而不是文件的 URL(例如`http://host:port/helloWorldApp/`)時,您可以**將 Tomcat 配置為提供目錄列表**或歡迎文件,或發出錯誤“404 頁面未找到”。 讓我們看看如何**啟用或禁用 tomcat 服務器**中的目錄列表。 ```java Table of Contents Enabling Directory Listing for ALL Webapps Enabling Directory Listing for any particular Webapp ``` ## 為所有 Webapp 啟用目錄列表 要為所有 Web 應用啟用目錄列表,您可以通過將“`default`” servlet 的“`listings`”從“`false`”更改為“`true`”來修改`<CATALINA_HOME>\conf\web.xml`,如下所示: ```java <!-- The default servlet for all web applications, that serves static --> <!-- resources. It processes all requests that are not mapped to other --> <!-- servlets with servlet mappings. --> <servlet> <servlet-name>default</servlet-name> <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class> <init-param> <param-name>debug</param-name> <param-value>0</param-value> </init-param> <init-param> <param-name>listings</param-name> <param-value>true</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <!-- The mapping for the default servlet --> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <!-- ==================== Default Welcome File List ===================== --> <!-- When a request URI refers to a directory, the default servlet looks --> <!-- for a "welcome file" within that directory and, if present, --> <!-- to the corresponding resource URI for display. If no welcome file --> <!-- is present, the default servlet either serves a directory listing, --> <!-- or returns a 404 status, depending on how it is configured. --> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> </welcome-file-list> ``` 上面的配置將 URL “`/`”(Web 上下文的根目錄)映射到 Java 類`DefaultServlet`。 我們**通過將 Servlet 的初始化參數`listings`更改為`true`來啟用目錄列表**。 如果用戶請求目錄,并且目錄列表已啟用并且包含`<welcome-file>`列表中的文件之一,則將提供歡迎文件; 否則,將提供目錄列表。 另一方面,如果接收到目錄請求且未啟用目錄列表,則服務器將返回錯誤“404 頁面未找到”。 ## 為任何特定的 Webapp 啟用目錄列表 如果只希望允許特定 Web 應用的目錄列表,則可以全局禁用“`<CATALINA_HOME>\conf\web.xml`”中的目錄列表,并在特定于應用的`WEB-INF\web.xml`中定義以下`<servlet>`和`<servlet-mapping>`,如下所示 : ```java <servlet> <servlet-name>DirectoryListing</servlet-name> <servlet-class>com.package.MyServlet</servlet-class> <init-param> <param-name>debug</param-name> <param-value>0</param-value> </init-param> <init-param> <param-name>listings</param-name> <param-value>true</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>DirectoryListing</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> ``` 請注意,啟用**目錄列表**對于測試服務器很方便,但對于生產服務器則不希望。 **祝您學習愉快!**
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看