我在$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="d:\myjsp" debug="0" reloadable="true" />
path是說明虛拟目錄的名字,如果你要隻輸入ip位址就顯示首頁,則該鍵值留為空;
docbase是虛拟目錄的路徑,它預設的是$tomcat/webapps/root目錄,現在我在webapps目錄下建了一個myjsp目錄,讓該目錄作為我的預設目錄。
debug和reloadable一般都分别設定成0和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"改成你的端口