Home > Back-end >  After the project deployment access path is empty
After the project deployment access path is empty

Time:09-16

Why the project after the server deployment request. GetSession () getServletContext () getRealPath (" upload ") access path is empty

CodePudding user response:

Whether to hand in the server automatically created this folder?

CodePudding user response:

Don't put the project folder subjects, on the outside, look at the web server, isn't that right,

CodePudding user response:

Empty folder won't deploy, need inside literally put a file,

CodePudding user response:

reference programmer Shawei reply: 3/f
empty folder won't deploy, need inside literally put a file,
Maven is the problem,

CodePudding user response:

See you how to deploy the project, it is better to the classpath, do not use the servletContext
 
Public class TestCode {

Public static void main (String [] args) {
String classpath=TestCode. Class. GetResource ("/"). GetPath ();
String projectPath=new File (the classpath). GetParentFile () getParentFile () getAbsolutePath ();
System. Out. Println (" class="+ classpath).
System. The out. Println (" project root directory="+ projectPath);
}

}

 
The classpath=/D:/app/project/muddy/test/WebRoot/WEB - INF/classes/
Project root directory=D: \ app \ project \ muddy \ test \ WebRoot

CodePudding user response:

You can try

 request. GetSession (). GetServletContext () getRealPath ("/") + "/upload" 
  • Related