【发布时间】:2023-03-31 20:00:01
【问题描述】:
我的 tomcat 有两个名为 webstock 和 webstockapi 的 Web 应用程序。然后两者都有一个名为 imgfold 的折叠。每次调用api并将图像文件上传到路径'webstockapi/imgfold',我必须将它们复制到另一个路径'webstock/imgfold'。调用webstockapi的api时如何获取webstock的web绝对路径。事实上,我的网络绝对路径是“/application/tomcat/webapps/webstockapi”和“/application/tomcat/webapps/webstock”。
现在我想出了一个办法,但它很复杂,而且必须有一个简单的办法。
//get the imgfold path when I call the webstockapi application
String uploadDir = session.getServletContext().getRealPath("/imgfold");
//my complex way to get the other appliction path
String destinationPicUrl=new File(session.getServletContext().getRealPath("/")).getParent()+
File.separatorChar +"webstock"+ File.separatorChar +"imgfold";
如何直接根据发布的web应用名称获取web绝对路径?
【问题讨论】:
标签: java spring-mvc tomcat centos