Display image in JSP with SPRING MVC
image, java, jsp, spring-mvc, url
Solution
Any static resource is also look for a URL Mapping in spring mvc, so static resources should be defined in the `springmvc-servlet.xml`.
Add the following entry to your MVC configuration. I assume that your static files in `resources` folder.
<mvc:resources mapping="/resources/**" location="/resources/" />
then static files can be accessible from the page.
<img src="/resources/images/logo.jpg" />
Problem
I am trying to display an image on a `jsp`. My image file is located at ``` MyApp/WebContent/images/logo.jpg ``` And my JSP pages are located at ``` MyApp/WebContent/WEB-INF/view/home.jsp ``` I have already tried to use the image by ``` <'img src="<%=request.getContextPath()%>/images/logo.jpg" /> ``` and ``` <'img src="<'c:url value='<%=request.getContextPath()%>/images/logo.jpg'></c:url></img> ``` Is this issue something because of my location hierarchy where I have placed my image? Really appreciate your help. Thank you. UPDATE: I've found the solution to my problem in: http://www.tutorialspoint.com/spring/spring_static_pages_example.htm I just have to use resource mapping in my `servlet.xml`. I really appreciate all of your kind answers. :)