天天看点

service层获取当前项目路径

在service层想要获取当前项目路径,不是在action传过来的,可以通过获取当前class所在路径的方法

String classPath = this.getClass().getResource("").getPath()

// 当前class所在目录

String srr - "/WEB-INF/classes/com/abc";

String rootPath = classPath.substring(0, classPath.length() - str.length());