The jsp web page does not display the image_eclipse environment in the browser to configure the virtual path of the jsp project in tomcat

Source: Internet
Author: User

The problem is that a local image is embedded in the jsp page. Because the image uploaded to the server is used, it is not put into the project, instead, all the images are put in a single folder, and the absolute path is used to display the images to be displayed, for example, in the uploadPhotos folder of the E disk, however, when the absolute path is used for display, the Code is as follows:

 

It can be displayed in the built-in browser of eclipse, but it is not displayed in other browsers,

Later I saw this article

Http://bbs.csdn.net/topics/320186157

It is realized that images on the server cannot be displayed on the client using an absolute path, because when the absolute path is sent to the client browser, there is no image corresponding to the absolute path on the client, so the virtual path is used.

Reference

 

Configure the virtual path in tomcat server. xml.
Assume that your project name is news and the uploaded directory is d:/upload.
Add the following line to server. xml:
<Context path = "/news/upload" docBase = "d:/upload"/>
You can use http: // localhost: 8080/news/upload/xxx.doc later.

 

I tried this many times, but the principle is clear, but it never works.

After trying to check for n times, I suddenly realized that my project was written in eclipse, and tomcat was started in eclipse. I changed the server before. xml is modified in the tomcat Directory, which is directed to startup in the bin directory of tomcat. role of bat when tomcat is started

I started tomcat in eclipse, so the modification didn't work. So I went to eclipse and tried to find tomcat server. xml,

Indeed, the tomcat configuration file is found in the Server directory of the workspace, and the server is modified here. xml is enough. If the path I mentioned is not found, try to find another place.

As for server. the xml modification method is the same as previously mentioned. If you don't understand it, you can take a look at the tutorials on the Internet. xml, but it is not clear that the modification to the tomcat directory is still in eclipse.

 

Author: jason0539

Weibo: http://weibo.com/2553717707

Blog: http://blog.csdn.net/jason0539 (reprinted please explain the source)

 

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.