標籤:
原文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中更改網站根目錄