4

I have the following servlet mapping present -

  <!--  Mapping Static Resources -->
     <mvc:resources mapping="/css/**" location="/resources/css/" />
     <mvc:resources mapping="/js/**" location="/resources/js/" />
     <mvc:resources mapping="/images/**" location="/resources/images/" />

My image link in the html is "/images/folder/imageName.jpg" - These images get me a 404 whereas if the change the link to "/images/imageName.jpg" and move the image to directly under the images folder it gets me the image.

Do I need to modify my servlet mapping in any way to take into account the hierarchical structure?

user1755645
  • 935
  • 2
  • 13
  • 22
  • This looks correct... have you checked in Firebug for the URLs the browser is using to fetch the images? There may be a relative path issue. – Peter Bratton Jan 29 '13 at 17:58
  • 2
    Could you give us the actual folder structure.From the mapping i understand /images is mapped to '/resources/images/' assuming the images are directly under /resources/images/ directory. So why would you access it "/images/folder/imageName.jpg" unless the image directory is '/resources/images/folder/' – Sudhakar Feb 03 '13 at 07:04

1 Answers1

3

You need to modify links to the images. When you write

<mvc:resources mapping="/images/**" location="/resources/images/" />

Then your HTTP requests to /resources/images are translated to webapp/images folder on the server. So in the html you should have something like this:

<img src="<spring:url value='/resources/images/logo.png'/>"
Badal
  • 4,078
  • 4
  • 28
  • 28
madhead
  • 31,729
  • 16
  • 153
  • 201