在spring web项目中获取WEB-INF/classes目录与WEB-INF/目录

场景:在spring web项目中获取WEB-INF/classes目录与WEB-INF/目录
 1.获取WEB-INF/classes 目录 

        /**1.获取WEB-INF/classes 目录  **/
	public static String getWebRootPath() {
		String webRootPath = CommonConfigUtils.class.getResource("/").getPath();
		return webRootPath;
	}

2.获取WEB-INF/

        /**2.获取WEB-INF/   目录*/
	public static String getWebInfPath() {
		String webRootPath = CommonConfigUtils.class.getResource("/").getPath();
		String webInfPath = webRootPath.substring(0,webRootPath.indexOf("classes"));
		return webInfPath;
	}

 以上,TKS.

猜你喜欢

转载自blog.csdn.net/zhangbeizhen18/article/details/85609884
今日推荐