Home > Java > javaTutorial > body text

How to add illustrations in jsp page

(*-*)浩
Release: 2020-09-15 13:42:59
Original
9874 people have browsed it

Methods for illustrations in jsp pages: first create "Dynamic Web Project"; then create an image folder under WebContent and put pictures in; then write the picture path code in "index.jsp"; finally Just run the program to view the image in your browser.

How to add illustrations in jsp page

Recently, I encountered a problem when I was new to Java Web, that is, images could not be displayed in jsp. I searched a lot of things on the Internet, and they basically talked about path problems, because I wrote How to add illustrations in jsp page based on my little HTML experience at the beginning, and I thought it was impossible to write the wrong path, but Later it was discovered that there were indeed some problems with the path. (This shows that you should not trust your half-baked experience too much)

Recommended courses: Java Tutorial.

First of all, we need to re-understand relative paths and absolute paths.

Relative path: refers to the path relationship with other files (or folders) caused by the path where this file is located.

Absolute path: The full path provided to the file, including the applicable protocol or drive letter. That is, the real full path of the file or directory on your home page on the hard disk.

According to my search on the Internet, absolute paths cannot be used directly in jsp. (Need to configure tomcat)

So use relative paths, so your picture folder and your jsp file must be at the same level (that is, in the same directory), so that you can call it well .

My best practices for this issue are given below

Preparation part: Set up a Dynamic Web Project. (My project name here is Shop3)

Create an image folder under WebContent and put the image How to add illustrations in jsp page.

How to add illustrations in jsp page

#Create the index.jsp file under WebContent.

How to add illustrations in jsp page

Here we can see that the jsp file and index file are in the same directory.

Write the image path code in index.jsp.




    <img  to add illustrations in jsp page alt="How to add illustrations in jsp page" >

Copy after login

Run the program and you can see the picture displayed in the browser.

How to add illustrations in jsp page

The above is the detailed content of How to add illustrations in jsp page. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
jsp
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template