0

I have these folders in my project:

Spring3MVC
> img
   > logo.png
> src
   > main
      > webapp
         > WEB-INF
            > pages
               > login.jsp

...

I want display logo.png in my .jsp file.

I tried:

<img src="../img/logo.png">
<img src="./img/logo.png">
<img src="img/logo.png">
<img src="*/img/logo.png">
<img src="<%=request.getContextPath()%>/img/logo.png"/>

But the result is:

WARNING: No mapping found for HTTP request with URI [/SpringMVC/img/logo.png] in   DispatcherServlet with name 'mvc-dispatcher'
mar 15, 2012 12:24:48 AM org.springframework.web.servlet.DispatcherServlet  noHandlerFound
WARNING: No mapping found for HTTP request with URI [/SpringMVC/*/img/logo.png] in   DispatcherServlet with name 'mvc-dispatcher'

What am I doing wrong?

Pika Supports Ukraine
  • 3,612
  • 10
  • 26
  • 42
user1199476
  • 121
  • 2
  • 5
  • 11
  • Is your image in your webapp? What path is it in? – davidfrancis Mar 14 '12 at 23:46
  • check out the answer from Joris in http://stackoverflow.com/questions/1483063/spring-mvc-3-and-handling-static-content-am-i-missing-something – ma cılay Mar 14 '12 at 23:46
  • when i doing everything like in link above, after add " " i cant load any page even login - No mapping found for HTTP request with URI [/SpringMVC/login] – user1199476 Mar 15 '12 at 00:54

2 Answers2

0

I had the same problem and resolved it by placing images in the server's directory structure as opposed to the portlet's. I'm using apache-tomcat and have it downloaded under:

C:\apache-tomcat-5.5.25\ 

In it there is a folder called "webapps" and I created a subfolder for my images there:

C:\apache-tomcat-5.5.25\webapps\portal_content\img

From the portlet JSP (i.e. view.jsp) I reference the image as such:

<"img src="/portal_content/img/my_image.gif">
Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
ayoub
  • 1
  • 1
0

because the "img" directory should be under src/main/webapp

Whatever IDE you're using to deploy your app (or build software which is packaging it probably doesn't have any idea about your "img" directory. It will simply do this:

1.  Copy all your classes into <deploy>/WEB-INF/class
2.  Copy all your dependencies into <deploy>/WEB-INF/lib
3.  Copy all resources from src/main/webapp into <deploy>
4.  Copy your defined web.xml into <deploy>/WEB-INF
Matt
  • 11,523
  • 2
  • 23
  • 33