您的位置:首页 > 产品设计 > UI/UE

java后台获取服务器的相对路径,不用request.getSession().getServletContext()和ServletActionContext

2014-04-14 15:12 661 查看
String rootPath = this.getClass().getResource("/").getPath(); //获取当前文件的路径

rootPath = rootPath.replaceAll("%20", " ");//空格转换的问题,显示的问题。

String webInfoPath = new File(rootPath).getParent();// WEB-INF 目录的物理路径

String abc = new File(webInfoPath).getParent();// WebRoot 目录的物理路径

abc = abc.replaceAll("\\\\", "/");
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐