首页 > 技术文章 > 获取项目路径

jbml-154312 2017-10-19 15:41 原文


 获取项目路径
1.this.getClass().getClassLoader().getResource("/").getPath();
 getClass().getProtectionDomain().getCodeSource().getLocation().getPath();
 2.req.getSession().getServletContext().getRealPath("/resources/upload");
 3.servletContext.getRealPath("/").substring(0, servletContext.getRealPath("/").lastIndexOf("seawin-webapp-base"))

推荐阅读