java获取webroot下面的文件路径

/**
	 * 
	 * @return WebRoot目录的绝对路径
	 */
	public static String getWebRootAbsolutePath() {
		String path = null;
		String folderPath = Path.class.getProtectionDomain().getCodeSource()
				.getLocation().getPath();
		if (folderPath.indexOf("WEB-INF") > 0) {
			path = folderPath.substring(0, folderPath
					.indexOf("WEB-INF/classes"));
		}
		return path;
	}

你可能感兴趣的:(Path)