/**
* 获取web应用路径
* @Description : 方法描述
* @Method_Name : getRootPath
* @return
* @return : String
* @Creation Date : 2013-12-13 下午9:09:28
* @version : v1.00
* @throws UnsupportedEncodingException
* @Author : zyn
* @Update Date :
* @Update Author : zyn
*/
public static String getRootPath() throws UnsupportedEncodingException {
String classPath = WebHelper.class.getClassLoader().getResource("/").getPath();
// "/" 表示class 根目录
String rootPath = "";
// windows下
if ("\".equals(File.separator)) {
rootPath = classPath.substring(1, classPath.indexOf("/WEB-INF/classes"));
rootPath = rootPath.replace("/", "\");
rootPath = URLDecoder.decode(rootPath, "UTF-8");
}
// linux下
if ("/".equals(File.separator)) {
rootPath = classPath.substring(0, classPath.indexOf("/WEB-INF/classes"));
rootPath = rootPath.replace("\", "/");
rootPath = URLDecoder.decode(rootPath, "UTF-8");
}
return rootPath;
}