java web应用访问tomcat目录外文件的路径映射问题

来源:互联网 发布:linux怎么关机 编辑:程序博客网 时间:2024/06/05 14:56

只需要编辑%tomcathome%\conf\server.xml文件,在标签中增加如何代码即可:

<Context docBase="D:/autotest_file/local/report" path="/report" debug="0" reloadable="true" />

其中docBase属性指定的为文件实际存储路径,path属性指定的为文件访问路径;如在浏览器中访问http://localhost/autotest/report/report.html实际指向的文件地址为D:/autotest_file/local/report/report.html

PS:
1. 路径最后面不要再添加/,否则报错。
2. 调试时如果在eclipse中,需在eclipse中的Servers/tomcat/server.xml中添加配置代码,eclipse会自动添加至tomcat实际所在路径配置文件中,上线时直接在线上%tomcathome%\conf\server.xml中添加即可。

0 0
原创粉丝点击