0

This is my project folder structure. I have resources folder under webapp. Source _ main -webapp - resources adminlogin.jpeg

I have one jsp page adminlogin.jsp which contain 1 image.But When ever I try to access this page I get page but not image. This is my SpringDispatcher-servlet.xml

   <i><context:component-scan base-package="ShoppingOnline" />
   <mvc:resources mapping="/resources/**" location="/resources/" />
   <context:annotation-config />
   <mvc:annotation-driven/> 
   <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
   <property name="prefix" value="/WEB-INF/jsp/" />
   <property name="suffix" value=".jsp" />
   </bean>
   </i>

This is my jsp page

 <html> 
 <body>
 <img src="/adminlogin.jpeg" alt="ADMIN LOGIN">
 </body>
 </html> 

I have seen many example in your site very one has given one soultion. but no has explain how its work in folder structure with example.I have made project in eclipse with the help of maven and In my folder structure the resources file is inside the web-inf folder.I haven't seen a single good example in this sites. Please if u explain,explain with a good example how it is work if the resource is inside the web inf folder and when the resources is outside the web inf folder. Please also let me know my mistake. Thanks for helping.

Manoj Singh
  • 1,329
  • 2
  • 13
  • 24

1 Answers1

0

Add your static files to webapps > resources

servlet.xml

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

then static files can be accessible from the page.

in Jsp:

<img src="/resources/images/yourimage.jpg" />
hurricane
  • 6,521
  • 2
  • 34
  • 44