java 獲取tomcat webapps目錄路徑
阿新 • • 發佈:2019-01-03
/**
* 獲取tomcat webapps目錄
* @param request
* @return
*/
public static String getTomcatWebappsPath(HttpServletRequest request){
String tomcatRoot = request.getSession().getServletContext().getRealPath("/");
String[] foo = tomcatRoot.split("/");
StringBuilder tomcatWebAppsBuilder = new StringBuilder();
int i = 0;
for(String paths : foo){
++i;
if(i != foo.length){
tomcatWebAppsBuilder.append(paths);
tomcatWebAppsBuilder.append("/");
}
}
String tomcatWebApps = tomcatWebAppsBuilder.toString();
return tomcatWebApps;
}
* 獲取tomcat webapps目錄
* @param request
* @return
*/
public static String getTomcatWebappsPath(HttpServletRequest request){
String tomcatRoot = request.getSession().getServletContext().getRealPath("/");
String[] foo = tomcatRoot.split("/");
StringBuilder tomcatWebAppsBuilder = new StringBuilder();
int i = 0;
for(String paths : foo){
++i;
if(i != foo.length){
tomcatWebAppsBuilder.append(paths);
tomcatWebAppsBuilder.append("/");
}
}
String tomcatWebApps = tomcatWebAppsBuilder.toString();
return tomcatWebApps;
}