public static String getServletRealPath(HttpServletRequest request) {
if (request == null) {
return "";
}else{
String rootPath = "";
try {
ServletContext context = request.getServletContext();
if(context!=null){
rootPath=context.getRealPath("/");
}
if (StringUtils.isBlank(rootPath) ) {
rootPath = JEICommon.class.getResource("/").getPath();
String endWith = "WEB-INF/classes/";
if (rootPath.endsWith(endWith)) {
rootPath = rootPath.substring(0,
rootPath.length() - endWith.length());
}
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
return rootPath;
}
}