简体   繁体   中英

How to include an image in a jsp page?

I'm developing a web application using Hibernate , Spring and JSP .

In my jsp page I included images as the following :

<img src="img/logo/logo.png" alt="">

but they are not displayed when I run my jsp page.

The jsp page is located in :

WEB-INF/index.php

this jsp page calls three other pages in the same folder as the following :

<%@ include file="header.jsp" %>
    <%@ include file="sidebar.jsp" %>
    <%@ include file="main.jsp" %>

and images are located in :

WEB-INF/img

How can I solve this problem ?

It may be possible that the image not display because of some path problem so that provide full context path and try it will work for you

<img src="${pageContext.servletContext.contextPath}/img/logo/logo.png" alt="">

Try this one it maybe help you

这对你有用

<img src="../img/logo/logo.png" alt="">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM