Tomcat中更改網站根目錄

來源:互聯網
上載者:User

標籤:

原文http://www.codesec.net/view/401617.html

 

1.tomcat原來的預設根目錄是http://localhost:8080,如果想修改訪問的根目錄,可以這樣:

找到tomcat的server.xml(在conf目錄下),找到:

複製代碼 代碼如下:

<Host name="localhost" appBase="webapps"
       unpackWARs="true" autoDeploy="true"
       xmlValidation="false" xmlNamespaceAware="false"></Host>
在</Host>前插入:

複製代碼 代碼如下:

<Context path="" docBase="D:/eclipse3.3/jb51.net/tomcat/" debug="0"/>

其中D:/eclipse3.3/jb51.net/tomcat/就是我想設定的網站根目錄,然後重啟tomcat。

再次訪問http://localhost:8080時,就是直接存取D:/eclipse3.3/jb51.net/tomcat/目錄下的檔案了。
2.tomcat的web.xml(在conf目錄下),在該檔案中找到

複製代碼 代碼如下:

    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
這是tomcat預設的3個檔案,當你輸入指定路徑後,tomcat會自動尋找這3個頁面。如果你想讓tomcat自動找到自己的頁面,比如main.jsp。可以修改上面資訊為:

複製代碼 代碼如下:

    <welcome-file-list>
        <welcome-file>main.jsp</welcome-file>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    
這樣就可以了。

Tomcat中更改網站根目錄

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.