SerhatCan
SerhatCan

Reputation: 590

Images not found in Spring - can not find resources folder

I have the following folder structure. I added mvc annotation and resources path but when I try call the resources in home.jsp like <img src= "/resources/images/spitter_avatar.png" />, it can't find anything.

Folder structure:

enter image description here

Here is my code in my servlet-config.xml file for resources:

<mvc:annotation-driven/>
<mvc:resources mapping="/resources/**" location="/resources/" />

Upvotes: 1

Views: 3907

Answers (3)

kyleryan1291
kyleryan1291

Reputation: 29

  1. The resources folder must be located inside the WebContent folder.
  2. Place ${pageContext.request.contextPath} before your items url on the jsp page. Example:
${pageContext.request.contextPath}/resources/images/springlogo.svg

Upvotes: 0

Pravin
Pravin

Reputation: 1147

<img src= "resources/images/spitter_avatar.png" /> 

try above remove "/" before resources

Upvotes: 6

Oomph Fortuity
Oomph Fortuity

Reputation: 6108

if you wanted to start with / , then use JSTL C tag

<img src= "<c:url value="/resources/images/spitter_avatar.png"></c:url>" /> 

Upvotes: 1

Related Questions