Java Web Implementation reads the image under the specified drive letter (ii)

Source: Internet
Author: User

Previously wrote an article on how to read the image under the specified drive letter, although the function can be implemented, but the use of the I/O flow, the efficiency is not high. Now there is a better way to use and more convenient.

We know that when our images are placed under Tomcat under WebApps's app directory, using src= "127.0.1:8080/xx/123.png" This way you can access the images. So if we can use the specified folder as a Tomcat workspace, then we can access the image directly.

All we need to do is add in Tomcat's Conf->server.xml host:

<context path= "/img" docbase= "H:/kk"         debug= "0" reloadable= "false" crosscontext= "false" verbosity= " DEBUG >     </Context>

Where path is the virtual path, Docbase is the specified folder.

We put 123.png images in the H:/KK, we can access our images in the browser input 127.0.0.1:8080/img/123.png.

Java Web Implementation reads the image under the specified drive letter (ii)

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.