Image directory not accessible in Spring MVC

In my Spring MVC app, I have the following directory structure:
- webapp
- - resources
- - images

In a JSP page, I am trying to display an image from the images directory with the following simple code:
<img src="/images/filename.jpg" alt="">

However, I am getting a 404 response - the resource is not found. The strange thing is, when I place the same image in the parallel resources directory, it shows up correctly.
graham on 19-01-2013 11:36
It turned out I was missing a resource configuration. In my servlet-context.xml, I had the following mapping for Spring static resources:
<mvc:resources mapping="/resources/**" location="/resources/" />

What I needed to do was to add:
<mvc:resources mapping="/images/**" location="/images/" />

Now the contents of the images folder are available.
graham on 19-01-2013 11:38

Post an answer

Do you have a solution to this problem, or want to comment on it? Other users will appreciate your help!
Your answer or comment:
Show formatting hints
HTML is disallowed, but in your text you can use the following markup
  • [code][/code] for a block of code
  • [tt][/tt] for inline code
  • [link]link href|link anchor[/link] for links
  • [b][/b] for bold text
+ Ask a question
If you have a technical question related to programming and computers, ask it here. Other users will help you solve it!
Unanswered questions
Share your knowledge by helping others solve their problems