获取服务器classes根路径
/**
* 获取web应用路径
* @Description : 方法描述
* @Method_Name : getRootPath
* @return
* @return : String
* @Creation Date : 2013-12-13 下午9:09:28
* @version : v1.00
* @throws UnsupportedEncodingException
* @Author : zyn * @Update Date :
* @Update Author : zyn
*/
public static String getRootPath() throws UnsupportedEncodingException {
// String classPath = Object.class.getClass().getResource("/").getPath();
String classPath = WebHelper.class.getClassLoader().getResource("/").getPath();//服务器启动才好用
// "/" 才是class 根目录
String rootPath = "";
// windows下
if ("\\".equals(File.separator)) {
rootPath = classPath.substring(1, classPath.indexOf("/WEB-INF/classes"));
rootPath = rootPath.replace("/", "\\");
rootPath = URLDecoder.decode(rootPath, "UTF-8");
}
// linux下
if ("/".equals(File.separator)) {
rootPath = classPath.substring(0, classPath.indexOf("/WEB-INF/classes"));
rootPath = rootPath.replace("\\", "/");
rootPath = URLDecoder.decode(rootPath, "UTF-8");
}
return rootPath;
}
获取服务器classes根路径的更多相关文章
- Java Web获取Web应用根路径
最基本的 1,request.getRealPath("/");这个方法已不推荐用 2,在Servlet 里用this.getServletContext().getRealPat ...
- js获取系统的根路径实现介绍
js如何获取系统的根路径,在本文给出了详细的方法 function getBasePath(){ var obj=window.location; var contextPath=obj.pathna ...
- js获取当前项目根路径URL (转自CSDN 红领巾-sunlight)
/** * //获取当前项目根路径 * @return {TypeName} */ function getRootPath(){ //获取当前网址,如: http://localhost:8083/ ...
- js获取网站项目根路径
//js获取项目根路径,如: http://localhost:8083/uimcardprj function getRootPath(){ //获取当前网址,如: http://localhost ...
- 在HTML页面中获取当前项目根路径的方法
在HTML页面获取项目根路径的方法: function getRootPath(){ var curPageUrl = window.document.location.href; var rootP ...
- asp获取虚拟目录根路径
<% TempArray = Array("account_book","admin","ajaxFile","catalo ...
- jsp笔记----jsp常用的的获取项目的根路径
<% String path = request.getContextPath(); String basePath = request.getScheme() + "://" ...
- 在java web中获取该项目的根路径
在jsp页面中: <% String path = application.getRealPath("").replace("\\","\\\\ ...
- python 获取项目的根路径
root_path = os.path.abspath(os.path.dirname(__file__)).split('shippingSchedule')[0] shippingSchedule ...
随机推荐
- redis学习(六)主从复制
主从复制:主机更新数据后,根据配置和策略,自动同步到备机的master/slaver机制,master以写为主,slaver以读为主.redis支持主从复制. 下面通过实例来讲解主从复制的四个模式: ...
- javaScript 笔记(4) -- 弹窗 & 计时事件 & cookie
弹窗 可以在 JavaScript 中创建三种消息框:警告框.确认框.提示框. 警告框:经常用于确保用户可以得到某些信息. 当警告框出现后,用户需要点击确定按钮才能继续进行操作. 语法: window ...
- 江南乐(bzoj 3576)
Description 小A是一个名副其实的狂热的回合制游戏玩家.在获得了许多回合制游戏的世界级奖项之后,小A有一天突然想起了他小时候在江南玩过的一个回合制游戏. 游戏的规则是这样的,首先给定一 ...
- Linux Mint---安装篇
先前接触过Debian6,埋头折腾已经是好几年前的事情了,后来就放下了,现在工作之余时间比较多,正好debian8.1出来了,于是乎装了个debian用,结果,自己其实还是一个菜蛋而已,连软件源怎么设 ...
- 长沙理工校赛I题题解-连续区间的最大公约数
题目来源https://www.nowcoder.com/acm/contest/96/I 解题前们需要先知道几个结论: 首先,gcd是有区单调性的: gcd(L,R)>=gcd(L,R+d) ...
- 《Linux命令行与shell脚本编程大全 第3版》Linux命令行---22
以下为阅读<Linux命令行与shell脚本编程大全 第3版>的读书笔记,为了方便记录,特地与书的内容保持同步,特意做成一节一次随笔,特记录如下:
- 使用中科大源下载android源码
我的系统时manjaro linux 最新版的,安装过了git和curl软件 一.如果没有安装的同学,请使用命令: pacman -S git curl 我这里安装了python3和python2,但 ...
- [转]谈谈Java中的语法糖
*该博客转自 http://blog.csdn.net/danchu/article/details/54986442 语法糖(Syntactic Sugar),也称糖衣语法,指在计算机语言中添加的某 ...
- myeclipse服务器"未能创建视图:抛出意外异常。"
找到对应目录 Workspaces\.metadata\.plugins\org.eclipse.core.runtime\.settings 下的 com.genuitec.eclipse.ast. ...
- AC日记——Car的旅行路线 洛谷 P1027
Car的旅行路线 思路: 这题不难,就是有点恶心: 而且,请认真读题目(就是题目卡死劳资): 来,上代码: #include <cmath> #include <cstdio> ...