前置条件
OS:Ubuntu20
tomcat下载
1.打开 http://tomcat.apache.org/ 侧边导航点击 Download->tomcat8,下载 tar.gz (pgp, sha512)
2.解压 tar -zxf apache-tomcat-8.5.68.tar.gz 到home目录下(或其他自己喜欢的目录)
tomcat配置
1.修改conf下server.xml文件,在末尾host内添加:
<!-- add for file access -->
<Context path="/html" docBase="/home/xxx/Workspace/browser/html" reloadable="true" debug="0" crossContext="true"/>
注意:path为url中的文件目录,docBase为存放文件的磁盘实际目录
2.修改conf下web.xml文件,找到listings,改为true
<init-param>
<param-name>listings</param-name>
<param-value>false</param-value>
</init-param>
修改为:
<init-param>
<param-name>listings</param-name>
<param-value>true</param-value>
</init-param>
3.浏览器输入:http://localhost:8080/html后即可浏览文件目录,可下载