java web项目 图片资源与部署目录分离,设置服务器的虚拟路径

   在开发WEB项目的时候,有时候需要用户上传一些图片文件之类的,传统做法是上传到部署目录下,这样会造成一个问题,当我们要重新部署项目的时候,发布一个新的war包,就要求删除之前的项目文件夹,这时候要保留用户上传的资源文件,就要把资源文件复制出来,然后项目部署成功之后又复制进部署目录,这样做很麻烦,为了避免这个问题,就需要将资源文件夹做成一个虚拟目录。

文件后台保存时保存路径填写对应文件夹的绝对路径就可以了。

例如:L:\sourcefile\studenticon

注意:若使用eclipse,则配置的虚拟目录是不起作用的哦。

配置server.xml文件

<Context docBase="C:/Program Files/Apache Software Foundation/Tomcat 9.0/webapps/CollegeLiveSourcefile/sourcefile/studenticon" path="/sourcefile/studenticon" reloadable="true" />

<Context docBase="C:/Program Files/Apache Software Foundation/Tomcat 9.0/webapps/CollegeLiveSourcefile/sourcefile/examfile" path="/sourcefile/examfile"  reloadable="true" />
 
<Context docBase="C:/Program Files/Apache Software Foundation/Tomcat 9.0/webapps/CollegeLiveSourcefile/sourcefile/examimage" path="/sourcefile/examimage"  reloadable="true" />
 
<Context docBase="C:/Program Files/Apache Software Foundation/Tomcat 9.0/webapps/CollegeLiveSourcefile/sourcefile/courseimage" path="/sourcefile/courseimage"  reloadable="true" />

<Context docBase="C:/Program Files/Apache Software Foundation/Tomcat 9.0/webapps/CollegeLiveSourcefile/sourcefile/Image" path="/sourcefile/Image"  reloadable="true" />

   

转载自:http://blog.csdn.net/LiMing_0820/article/details/53896970

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值