获取web应用路径 // "/" 表示class 根目录
/**
* 获取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 = 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;
}
获取web应用路径 // "/" 表示class 根目录的更多相关文章
- java ,js获取web工程路径
一.java获取web工程路径 1),在servlet可以用一下方法取得: request.getRealPath(“/”) 例如:filepach = request.getRealPath(“/” ...
- Servlet之ServletContext获取web上下文路径、全局参数、和Attribute(域)
1)获取web上下文路径 public void doGet(HttpServletRequest request, HttpServletResponse response) throws Serv ...
- 【转】Spring 获取web根目录 (Spring线程获取web目录/路径/根目录,普通类获取web目录)
不使用Spring,怎样能在Listener启动的Thread中获取web目录,还真不完全确定.其实我觉得实际代码也很简单.就是基于普通的listener,然后在listener中获取web目录并放到 ...
- Java获取web项目路径
File f = new File(WebPath.class.getResource("/").getPath()); String path = f.getParentFile ...
- 获取web服务器路径的方法 getResourceAsStream
1.先获取 serlvetContext对象 2.调用getResourceAsStream 在方法里 "\"表示当前web的根目录 还要拼接上具体的文件路径 ServletC ...
- JS 获取WEB请求路径
function getRealPath(){ //获取当前网址,如: http://localhost:8083/myproj/view/my.jsp var curWwwPa ...
- C#里面获取web和非web项目路径
非Web程序获取路径几种方法如下: 1.AppDomain.CurrentDomain.BaseDirectory 2.Environment.CurrentDirectory 3.HttpRunt ...
- ASP.NET获取web应用程序的路径
服务器磁盘上的物理路径: HttPRuntime.AppDomainAppPath虚拟程序路径: HttpRuntime.AppDomainAppVirtualPath 任何于Request/Http ...
- 【转】Java Web 项目获取运行时路径 classpath
Java Web 项目获取运行时路径 classpath 假设资源文件放在maven工程的 src/main/resources 资源文件夹下,源码文件放在 src/main/java/下, 那么ja ...
随机推荐
- 开源免费的C/C++网络库(c/c++ sockets library)(转)
原文转自 http://blog.csdn.net/weiwangchao_/article/details/8730199 (1)ACE 庞大.复杂,适合大型项目.开源.免费,不依赖第三方库,支持跨 ...
- tcpreplay 缓存算法研究
一. 缓存算法 1.1 算法目的 流量拆分算法的运算会明显影响包的发送速率,为了提高发送速率, tcpreplay 使用了缓存机制,该部分代码也封装在tcpprep工具里,运行 tcpprep ( ...
- 【QC】安装
QC不支持win8 1. 开启win8自带的IIS服务. 在控制面板-程序-启用或关闭Windows功能-Internet Information Service
- (3)Oracle提供的.net连接驱动
老的visual studio不能用 ( .NET 4 以后才能用) Oracle Data Access Components (ODAC) 是什么? ODAC中文名称叫Oracle访问存取组件,里 ...
- poj2774(最长公共子串)
poj2774 题意 求两个字符串的最长公共子串 分析 论文 将两个字符串合并,中间插入分隔符,在找最大的 height 值的时候保证,两个字符串后缀的起始点分别来自原来的两个字符串. code #i ...
- JD
General Description: The role is responsible for China COE Operations Team’s data and cost analysis, ...
- Find the Duplicate Number -- LeetCode
Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), pro ...
- 【bzoj4152】【The Captain】最短路(堆优化)(浅尝ACM-B)
[pixiv] https://www.pixiv.net/member_illust.php?mode=medium&illust_id=62834538 Description 给定平面上 ...
- eclipse无法导入Android工程的解决办法
我以前在windows平台下写的android源代码无法通过import"existing project into workspace"导入到mac的eclipse中,直接搜不见 ...
- Bluetooth篇 开发实例之五 为什么无线信号(RSSI)是负值?
原文:http://www.cnblogs.com/lele/articles/2832885.html 为什么无线信号(RSSI)是负值 答:其实归根到底为什么接收的无线信号是负值,这样子是不是 ...