您的位置:首页 > 其它

servlet得到webroot路径

2016-07-02 08:54 302 查看
//file:/F:/WorkSpace/Myeclipse_Workspace_1/.metadata/.me_tcat7/webapps/Hello/WEB-INF/classes/
String classessPath = this.getClass().getResource("/").toString();

//F:/WorkSpace/Myeclipse_Workspace_1/.metadata/.me_tcat7/webapps/Hello/WEB-INF/classes/
String classessRealPath = classessPath.replace("file:/", "");

String webRootPath = classessRealPath.replace("WEB-INF/classes/", "");

File file = new File(webRootPath + "lrc");
if (!file.exists()) {
file.mkdirs();
}

System.out.println(file.getAbsolutePath());
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  servlet webroot