怎么修改TOMCAT的默認主頁為你自己項目的主頁


如何修改TOMCAT的默認主頁為你自己項目的主頁

(最合適的)
最直接的辦法是,刪掉tomcat下原有Root文件夾,將自己的項目更名為Root。

我在$tomcat/webapps/下建了個myjsp目錄作為我網站的默認目錄,在myjsp中有一個a.jsp文件,該文件要作為我網站的默認主頁。

修改配置文件:

首先,修改$tomcat/conf/server.xml文件。
在server.xml文件中,有一段如下:
……
<engine name="Catalina" defaultHost="localhost">
<host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
……
<host>
</engine>
……
在<host></host>標簽之間添加上:

<Context path="" docBase="myjsp" debug="0" reloadable="true" />

path是說明虛擬目錄的名字,如果你要只輸入ip地址就顯示主頁,則該鍵值留為空;

docBase是虛擬目錄的路徑,它默認的是$tomcat/webapps/ROOT目錄,現在我在webapps目錄下建了一個myjsp目錄,讓該目錄作為我的默認目錄。

debug和reloadable一般都分別設置成0和true。
<Context path="" docBase="myjsp" debug="0" reloadable="true"/>

然后,修改tomcat/conf/web.xml文件。
在web.xml文件中,有一段如下:
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
在<welcome-file-list>與<welcome-file>index.html</welcome-file>之間添加上:

<welcome-file>a.jsp</welcome-file>

更改端口
<Connector port="8080" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" redirectPort="8443" acceptCount="100" debug="0" connectionTimeout="20000" disableUploadTimeout="true" /> 


將port "8080"改成80端口

保存上述兩個文件后重啟tomcat,在瀏覽器地址欄內輸入"http://localhost/",顯示a.jsp頁面的內容。
 
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM