Reputation: 69
I have tried to put absolute path in jsp tag. But it doesn't display the image.
<div class="container">
<img src="<c:url value='${pageContext.request.contextPath}/images/default-
user-image.png'/>" alt="userImage" />
</div>
Upvotes: 0
Views: 177
Reputation: 2675
JSTL <c:url>
tag has the context
attribute ( optional) and it is set the current application as the context by default.
So, you can use like this without contextPath
:
<c:url value='/images/default-user-image.png'/>
Secondly, To serve static resources with Spring, check your static handlers whether it works correctly or not.
For your example, add the following mapping in XML might work.
<mvc:resources mapping="/images/**" location="/images/" />
Upvotes: 2