String path= This.getservletcontext (). Getrealpath ("") +request.getrequesturi (). substring (Request.getcontextpath () . Length ());
(Request.getcontextpath () is the project name so the URI needs to be stripped of the project name This.getservletcontext (). Getrealpath ("") already contains the project name
String Dirpath = new File (path). GetParent ();
This.getservletcontext (). Getrealpath ("") can also be used with Application.getrealpath (""), not enough as if to say that the bean is not recommended to use
It can also be written directly into it.
String path= This.getservletcontext (). Getrealpath (Request.getrequesturi (). substring (Request.getcontextpath (). Length ()));//Gets the path to the current JSP file
String dirpath= New File (path). GetParent (); Just return a "/"
Get the d://xxxxx/xxxx/xxxx/xxxxx get JSP the directory at the very back is no/
So dirpath the file name after the file name plus/
such as String filepath = dirpath+ "/a.txt";
http://blog.csdn.net/zbz0425/article/details/8109406
String Realpath = Request.getrealpath ("");//Project Absolute path
String Realpath = Request.getrealpath ("/upload");//path of the specified folder under the root directory path
This method gets the root path of the project you are deploying.
http://wenda.haosou.com/q/1378282656063583
Get Current Server Catalog file