如何將tomcat webapp目錄下的專案 路徑改為 / (原訪問路徑需要加專案名)
阿新 • • 發佈:2018-12-07
1.tomcat原來的預設根目錄是http://localhost:8080,如果想修改訪問的根目錄,可以這樣:
找到tomcat的server.xml(在conf目錄下),找到:
複製程式碼程式碼如下:
在前插入:
複製程式碼程式碼如下:
其中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>
這樣就可以了。