1.修改 welcome-file-list
找到 tomcat conf 文件夹下的 web.xml 文件中的 welcome-file-list (通常在最后面)
<welcome-file-list>
<welcome-file>1.html</welcome-file>
<welcome-file>2.html</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
这里面的文件定义了在 server 规定的 context 目录下的虚拟空间列表
会从上至下尝试去获取。修改至你默认主页的文件名
这里我已经修改了,默认是 index.html index.htm index.jsp
2.在 tomcat webapps 文件夹下 创建一个 new 文件夹 (名称随意)
并将你的主页文件放在里面
3.在同一文件夹下的 server.xml 中,添加一段特定字段
<Context path="" docBase="" reloadable="true"/>
具体位置如下
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
<Context path="" docBase="now" reloadable="true"/>
</Host>
修改 docBase=“” 中 “” 的字段为文件夹名,在这里就是 now