Tomcat configures the virtual path so that the uploaded files are separated from the server and the project files

Source: Internet
Author: User

    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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.