What is the effect of using a Tomcat virtual path? Simply say you can put the uploaded files in any place you want to send, while you can distinguish between the types of files, picture files specifically put in one place, compressed package files put in another place. In fact, how to configure the very simple, here in the window environment to explain! First find the Server.xml file in the Conf directory under the Tomcat directory in the Server.xml file <Host></Host> then add the two sentences in it <context path= "/demo/file" docBase= "D:\demo \file\file "></Context> <context path= "/demo/image" docbase= "D:\demo\File\image" ></Context> Explain the meaning of these two sentences with Tomcat running in this machine for example is generally http://localhost:8080 when you visit Http://localhost:8080/demo/file/xxx.zip or HTTP/// Localhost:8080/demo/image/xxx.jpg, Tomcat forwards the request to request the D-disk on the physical machine where Tomcat is located D:\demo\File\ File Xxx.zip files and xxx.jpg files when uploading files only need to store the corresponding files in the corresponding directory in the database to store files in the path: it is better to store in the database xxx.zip or xxxx.jpg such a file name why? This is more convenient for server migration! Let's say your tomcat server needs to switch to another physical machine, then the entire address originally stored in the database can not be used so, the better way is the server address information can be used to manage the configuration file, the full address of the request file is assembled in the background, so that even to do the migration &NBSP, also just change the configuration file, copy the file to the new physical machine, other non-Need to change! One more thing to keep in mind: when we do the tests, the development tools use Eclipse,eclipse to have a nasty place where the configuration information in Tomcat is reset every time you restart Tomcat! So the results are not visible! A little attention. The above purely personal humble opinion, for reference only!
Tomcat configures the virtual path so that the uploaded files are separated from the server and the project files