Tomcat的設置2——設置虛擬子目錄和歡迎頁
<Host name="localhost" appBase="webapps"unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context path="/testProject1" docBase="E:\apache-tomcat-test_project" />
<Context path="/testProject2" docBase="E:\apache-tomcat-test_project\tomatTest" />
</Host>
E:\apache-tomcat-test_project中有testIndex.html
通過https://127.0.0.1:8080/testProject1/testIndex.html可以訪問
E:\apache-tomcat-test_project\tomatTest中有testIndex.html
通過https://127.0.0.1:8080/testProject2/testIndex.html可以訪問
可以新增設置WEB-INF文件夾和其中的web.xml設置歡迎頁:
在tomatTest新增WEB-INF文件夾,在WEB-INF文件夾中添加文件web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<welcome-file-list>
<welcome-file>testIndex.html</welcome-file>
</welcome-file-list>
</web-app>
這樣訪問https://127.0.0.1:8080/testProject2就可以訪問testIndex.html頁麵了。
當然在基準目錄webapps放一個項目文件夾就可以直接訪問,通過MyEclipse開發部署經常會這麼做,這是基準目錄帶來的方便。
最後更新:2017-04-03 12:54:51