WEB 获取项目部署根目录
2013-08-29 11:53
211 查看
URL url = Function.class.getResource("Function.class");
String temppath = url.toString();
int startIndex = temppath.indexOf("file:");
int index = temppath.indexOf("WEB-INF");
basePath = temppath.substring(startIndex + "file:".length() + 1, index);
// 如果是linux的操作系统,并且开始没有file分隔符的话,那么要加上
if (System.getProperty("os.name").indexOf("Linux") != -1) {
if (!basePath.startsWith(File.separator)) {
basePath = File.separator + basePath;
}
}
String temppath = url.toString();
int startIndex = temppath.indexOf("file:");
int index = temppath.indexOf("WEB-INF");
basePath = temppath.substring(startIndex + "file:".length() + 1, index);
// 如果是linux的操作系统,并且开始没有file分隔符的话,那么要加上
if (System.getProperty("os.name").indexOf("Linux") != -1) {
if (!basePath.startsWith(File.separator)) {
basePath = File.separator + basePath;
}
}
相关文章推荐
- java 工程获取路径 web根目录。 项目classpath根目录 各种实用方法
- 2014.09.22 获取项目所在根目录下的文件(/WEB-INF/下的文件)
- java 工程获取路径 web根目录。 项目classpath根目录 各种实用方法 摘抄收藏
- java 工程获取路径 web根目录。 项目classpath根目录 各种实用方法
- java 工程获取路径 web根目录。 项目classpath根目录 各种实用方法 摘抄收藏
- java 工程获取路径 web根目录。 项目classpath根目录 各种实用方法 摘抄收藏
- java 工程获取路径 web根目录。 项目classpath根目录 各种实用方法
- tomcat中运行正常的web项目部署至websphere后,spring无法获取bean
- java 工程获取路径 web根目录。项目classpath根目录 各种实用方法
- java 工程获取路径 web根目录。 项目classpath根目录 各种实用方法
- eclipse部署web项目无法将项目发布到本地的tomcat的问题解决
- LINUX部署WEB项目(TOMCAT安装和配置)
- Eclipse中进行Gradle+Jetty部署的web项目的断点调试
- eclipse+tomcat热部署Web项目
- web获取项目绝对路径
- eclipse部署web项目至本地的tomcat但在webapps中找不到
- 将Eclipse中的Web项目部署到Tomcat
- 部署Maven项目到tomcat报错:java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderLi
- tomcat部署web项目
- 如何部署web项目