获取web服务器的根路径

/**
* 获取服务器WebRoot的绝对路径
* @return
*/
public String getWebRootPath(){
	String classpath = this.getClass().getResource("SysConfig.class").toString();
	String rootpath = classpath.substring(classpath.indexOf(":")+2, classpath.lastIndexOf("WEB-INF")).replaceAll("%20", " ");
	return rootpath;
}

你可能感兴趣的:(java,Web)