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)