1. 修改server.xml文件,在Host标签中加入
<Context path="/file" docBase="F:\Downloads" reloadable="true" debug="0" crossContext="true"/>
2. 修改web.xml文件,把listings的value修改为true
<servlet>
<servlet-name>default</servlet-name>
<servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>listings</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
配置完成后开启Tomcat访问localhost:8080/file就可以访问到docBase配置的目录了