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
通过http://127.0.0.1:8080/testProject1/testIndex.html可以访问

E:\apache-tomcat-test_project\tomatTest中有testIndex.html
通过http://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>

这样访问http://127.0.0.1:8080/testProject2就可以访问testIndex.html页面了。


当然在基准目录webapps放一个项目文件夹就可以直接访问,通过MyEclipse开发部署经常会这么做,这是基准目录带来的方便。

你可能感兴趣的:(tomcat,web.xml,虚拟子目录)