修改配置文件:
首先,修改$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頁面的內容。
如果只想輸入http://localhost就可以訪問自己的初始頁面,就需要將server.xml下的8080端口改成80端口
