获取服务器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 ...
随机推荐
- 【bzoj2186】[Sdoi2008]沙拉公主的困惑 欧拉函数
题目描述 大富翁国因为通货膨胀,以及假钞泛滥,政府决定推出一项新的政策:现有钞票编号范围为1到N的阶乘,但是,政府只发行编号与M!互质的钞票.房地产第一大户沙拉公主决定预测一下大富翁国现在所有真钞票的 ...
- BZOJ3462 DZY Loves Math II 【多重背包 + 组合数】
题目 输入格式 第一行,两个正整数 S 和 q,q 表示询问数量. 接下来 q 行,每行一个正整数 n. 输出格式 输出共 q 行,分别为每个询问的答案. 输入样例 30 3 9 29 1000000 ...
- 一两眼题(oneortwo)
一两眼题(oneortwo) 题目描述 给出n个整数,依次为a1,a2,...an.n<=50000. 你要进行K次操作,0 <= k < =1,414,213,562 每次操作你算 ...
- zookeeper与Kafka集群搭建及python代码测试
Kafka初识 1.Kafka使用背景 在我们大量使用分布式数据库.分布式计算集群的时候,是否会遇到这样的一些问题: 我们想分析下用户行为(pageviews),以便我们设计出更好的广告位 我想对用户 ...
- Codeforces Round #320 (Div. 2) [Bayan Thanks-Round] E 三分+连续子序列的和的绝对值的最大值
E. Weakness and Poorness time limit per test 2 seconds memory limit per test 256 megabytes input sta ...
- springboot 热加载的问题 idea下的springboot热加载的
最近在学spring框架,使用的是springboot可以省去很多的配置,可谓是初学者的福音啊. 尤其是在刚写代码的时候,都想马上看到自己写出来的效果,看看能不能输出hello world,所以要不断 ...
- day5感想
---恢复内容开始--- 我感觉自己真的是太弱了,和那些从初中开始学的人TT 今天讲的数学,毕竟以前尖子生培训打过点基础,感觉还不错,但也仅限于听懂而已,打代码什么的…… 今天的内容: 一.数论 1. ...
- 用c#语言通过修改注册表改IE网页首页
原文发布时间为:2009-04-19 -- 来源于本人的百度文章 [由搬家工具导入] string key = @"HKEY_CURRENT_USER\Software\Microsoft\ ...
- python3 定义向量运算
from math import hypot #定义向量的构造方法 class Vector: def __init__(self,x=0,y=0): self.x=x; self.y=y; ''' ...
- hdu 4525(数学)
威威猫系列故事——吃鸡腿 Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Tota ...