Tomcat config virtual path with static resources

Source: Internet
Author: User

In the development process, we often encounter the picture/audio Video storage problem, this time we need to configure the server to store static resources of the virtual path

Step one: Open the Server.xml configuration file, which is in the tomcat/conf directory

Step two: The following figure embeds a context label under the host tag in the Server.xml file, path is the mapped web path, and Dobase is the physical path to the local disk. Context element Properties Introduction: Click to open the link

<context path= "/TG" docbase= "e:\ data" debug= "0" reloadable= "true"/>


Step three: How to access.

As described in step two picture, my static resource file is an img file under E disk, assuming I placed a tg.png picture in the img file, as shown above, you can access it via http://127.0.0.1:8080/tg/tg.png.

----------------------------------------------------------------------------------

Set Tomcat to allow access to static folder modify Web.xml file The following picture position to modify false to True


Web Access Map


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.