Home >Java >javaTutorial >Detailed explanation of examples based on compiler idea and tomcat server

Detailed explanation of examples based on compiler idea and tomcat server

零下一度
零下一度Original
2017-07-26 14:11:442297browse

The following will introduce to you the development based on the compiler idea and tomcat server. Friends who are interested in the two ways of loading image paths in Java web development should take a look.

(1) src="/image /1_it.jpg"

(2) src="localhost:8080/image/1_it.jpg"

Where localhost can be replaced with your computer IP, and the port number should also be changed accordingly.

The above are all tested and feasible in the web developed based on the compiler idea and tomcat server! It’s all about locating the location of the project first!

First of all, the picture and the project are not under the same drive letter. Pictures cannot be placed under projects.
In the JSP file this will not lead to the picture. Because when the JSP page references images, the path parsed on the page is: . In other words, when JSP imports images, it first searches in your project directory.
So if you want to introduce pictures of other drive letters in JSP, there are two ways to solve it:

Use virtual path to configure:
Add one in conf/server.xml under tomcat The code
in the middle of is as follows: