將tomcat歡迎頁(yè)面修改為自己項(xiàng)目的主頁(yè)

字號(hào):


    1.我在$tomcat/webapps/下建了個(gè)myjsp目錄作為我網(wǎng)站的默認(rèn)目錄,在myjsp中有一個(gè)a.jsp文件,該文件要作為我網(wǎng)站的默認(rèn)主頁(yè)。
    2.修改配置文件:
    首先,修改$tomcat/conf/server.xml文件。
    在server.xml文件中,有一段如下:
    ……
    <engine name=catalina defaulthost=localhost>
    <host name=localhost appbase=webapps
    unpackwars=true
    xmlvalidation=false xmlnamespaceaware=false>
    ……
    <host>
    </engine>
    ……
    3.在<host></host>標(biāo)簽之間添加上:
    <context path= docbase=myjsp debug=0 reloadable=true />
    path是說(shuō)明虛擬目錄的名字,如果你要只輸入ip地址就顯示主頁(yè),則該鍵值留為空;
    docbase是虛擬目錄的路徑,它默認(rèn)的是$tomcat/webapps/root目錄,現(xiàn)在我在webapps目錄下建了一個(gè)myjsp目錄,讓該目錄作為我的默認(rèn)目錄。
    debug和reloadable一般都分別設(shè)置成0和true。
    4.然后,修改$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>
    5.更改端口(該步驟可以省略)
    <connector port=8080 maxthreads=150 minsparethreads=25 maxsparethreads=75 enablelookups=false redirectport=8443 acceptcount=100 debug=0 connectiontimeout=20000 disableuploadtimeout=true />
    將port 8080改成你的端口
    保存上述兩個(gè)文件后重啟tomcat,在瀏覽器地址欄內(nèi)輸入,顯示a.jsp頁(yè)面的內(nèi)容。