Configure the external resource path for Tomcat (scenario: Web Project access to resources such as picture videos)

Source: Internet
Author: User

For a Web project, in addition to the text, pictures, videos and other media elements are also an important part of it. We know that if we use a lot of pictures and video resources in Web projects, we

It is common practice to store only the paths of resources such as pictures and videos in the database, and the Web project directly refers to the corresponding resource through the path, rather than storing the entire picture as a stream in the database.

Of course, for the system does not use a lot of pictures, or the picture quality requirements are not very high some small icons, we can also directly use the form of stay or with Base64 encoding in the form of longtext stored in the database.

The path to these resources can be configured without time and effort. However, his disadvantage is to increase the pressure on the database, only for that pattern is small, the database server performance is not too large requirements of small projects.

The advantage of configuring the external resource path for Tomcat is that he greatly reduces the pressure on the server and the database by only storing the path to the resource, uploading the image to a specified folder outside of Tomcat, and providing

A Web project reference under Wabapps in Tomcat.

Locate the Conf/server.xml file in the Tomcat installation directory and add the configuration to the <Host>......</Host> tab:

<!--video image resources Fload--><context docbase="C:\resources"  reloadable="true"  debug="0" path="/ Resources"/>

Where Docbase is the physical path to the folder, path is the access path to the folder.

Then restart Tomcat. Suppose there is a picture named Test.jpg under the Resources folder, and only "http://localhost:8080/resources/test.jsp" is required to access the picture resource.

Configure the external resource path for Tomcat (scenario: Web Project access to resources such as picture videos)

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.