java 获取服务器端的webapps路径
2012-11-01 10:12
363 查看
/** *获取服务器端的webapps路径 *@return */ publicStringfindServerPath(){ StringclassPath=this.getClass().getClassLoader().getResource("/").getPath(); try{ classPath=URLDecoder.decode(classPath,"gb2312"); }catch(UnsupportedEncodingExceptione){ e.printStackTrace(); } String[]strPath=classPath.split("/"); Stringpath=""; for(inti=0;i<strPath.length;i++){ if(i>0&&i<=3){ path=path+strPath[i]+"/"; } } returnpath; }
备注:StringfilePath=System.getProperty("user.dir")+File.separator+"src"+File.separator+"main"+File.separator+"webapp"+File.separator+"downloads"+File.separator;
相关文章推荐
- java 获取服务器端的webapps路径
- Java上传图片到服务器路径获取系列之--图片保存到Tomcat的webapps目录下
- java web获取上传的文件在服务器端的路径
- java 获取当前类所在项目的Tomcat/Resin 的webapps路径
- java 获取tomcat webapps目录路径
- 获取服务器端的webapps路径
- Java在不同环境下获取当前路径的方法--this.getClass().getResource("")
- JAVA获取CLASSPATH路径
- java中获取文件路径的几种方式
- java webservice服务器端获取request对象的三种方式
- 终极解决java获取路径问题
- java获取各种路径的方法
- java 项目 获取当前路径
- java获取项目路径
- Java获取当前路径
- JAVA中获取工程路径的方法
- java获取src/main/resources下的文件路径
- java 获取项目路径
- Java获取路径
- JAVA 获取系统路径