Search code examples
javajakarta-eefront-controller

is there any problem for a page in WEB-INF to access image in web pages folder


Hello i'm working on a j2ee web app with spring 3.0.5 implementing the front controller pattern, with it's dispatcher servlet without the controller using

<mvc:view-controller path="/" view-name="home"/>

with ViewResolver. the pages are in WEB-INF/views and images are in /public/images. it's seems like images are not showing even with width and height specify.

<img src="/public/images/Home.png" width="110px" height="110px" />

i'm wondering is there is something i'm ignoring or that i should know and do? thanks for reading this.


Solution

  • Yeah, you need to tell spring where to server static resources from. Try something like this:

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

    Here's a link to more documentation: http://static.springsource.org/spring/docs/current/spring-framework-reference/html/mvc.html check section 15.12.4