Java Web特殊情况获取工程路径

String ProjectPath = new DefaultResourceLoader()
.getResource("/").getFile().getAbsolutePath();
ProjectPath = ProjectPath.substring(0,ProjectPath.length()-15);

     这个方法是在没有request的情况下获取工程路径,这里需要截取字符串获取根目录“webapp”。

猜你喜欢

转载自aa80303857.iteye.com/blog/2378352