首先,修改$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:\hbjobwork\WebRoot5" reloadable="true" crossContext="true" >
path是說明虛擬目錄的名字,如果你要只輸入ip
docBase是虛擬目錄的路徑,它默認的是$tomcat/webapps/ROOT目錄,現在目錄已經指向到D:\hbjobwork\WebRoot5目錄,讓該目錄作爲我的默認目錄。
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>
保存上述兩個文件後重啓tomcat,在瀏覽器地址欄內輸入"http://localhost:8080/",顯示a.jsp頁面的內容。