1.获取webroot的路径方法:
在通过path = path.replaceAll("需要替换的项目名称", "替换的文件目录");
也可以通过属性配置文件来进行设置。例如:Config.Instance().getValue("UploadAppraiser")。
B:也可以通过获取当前文件用户文件:
String path = System.getProperty("user.dir").replace("bin", "webapps");
String path = request.getSession(true).getServletContext().getRealPath("/");
2.获取tomcat(webapps)的路径的方法:
A:String path = request.getSession(true).getServletContext().getRealPath("");在通过path = path.replaceAll("需要替换的项目名称", "替换的文件目录");
也可以通过属性配置文件来进行设置。例如:Config.Instance().getValue("UploadAppraiser")。
B:也可以通过获取当前文件用户文件:
String path = System.getProperty("user.dir").replace("bin", "webapps");