Experience:
Getrootpath1 is available in Tomcat and WebLogic as war packages.
Getrootpath1 is available in Tomcat and WebLogic as folders.
Public static string getrootpath1 (){
Return System. getproperty ("miugonavi. Root ");
}
Public static string getrootpath2 (){
String classpath = NULL;
Try {
// Touri () 20% to Space
Classpath = commonutil. Class. getclassloader (). getresource ("/"). touri (). getpath ();
} Catch (urisyntaxexception e ){
E. printstacktrace ();
}
String rootpath = "";
// In Windows
If ("\". Equals (file. separator )){
Rootpath = classpath. substring (1, classpath. indexof ("/WEB-INF/classes "));
Rootpath = rootpath. Replace ("/","\\");
}
// In Linux
If ("/". Equals (file. separator )){
Rootpath = classpath. substring (0, classpath. indexof ("/WEB-INF/classes "));
Rootpath = rootpath. Replace ("\\","/");
}
Return rootpath + file. Separator;
}