1.修改网站根目录
默认的网站根目录是tomcat安装路径下的wepapps文件夹,如果想要把网站目录放在其它目录下只需要做如下操作:
找到tomcat安装目录下的conf文件夹下的server.xml
打开server.xml文件,找到标签
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"></Host>
将appBase="webapps"修改为appBase=“自定义网站根目录”
并且在这条标签上面空白处添加如下标签内容
<Context path="" docBase="自定义网站根目录" debug="0"/>
然后就可以使用http://ip|域名/项目名/页面访问放在自定义网站路径下的网站了
2.添加或修改默认文档
找到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是子标签,每一个子标签代表一个默认文档选项,根据需要修改或添加子标签即可
例如:我想添加一个默认文档,默认访问default.html文件,修改后如下所示
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
</welcome-file-list>