I am using Spring MVC 3.0.
I have to load the images which exist in the folder “images” parallel to the WEB-INFdirectory.
I have the jsp files in WEB-INF/jsp folder.
The folder structure is:
-app
--images
--WEB-INF
---jsp
---classes
...
In web.xml the url mapping for DispatcherServlet is some thing like
<servlet-mapping>
<servlet-name>test</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
Now in JSP if I load the jsp in the following way:
<img src="<%=request.getContextPath()%>/images/calogo.jpg" />
Its now working as DispatcherServlet is intercepting it I guess.
Yes you are right. Your dispatcher is intercepting your request to display the images.
According to me when you try to access the image in your jsp file it will give you 404 error.
You need to include the following line of code in your servlet.xml file.
And then everything will work.
Hope this helps you.
Cheers.