I want to outsource my images outside the spring project folder. After some researches I found the mvc:resources tag, which seemed to be the perfect solution for my requirement.
app-servlet.xml
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<mvc:annotation-driven/>
<mvc:resources mapping="/pics/**" location="file:/c:/Tomcat_6/webapps/external_resources/" order="0" />
JSP Call:
<img src="<c:url value="/pics/test.png"/>" />
I have no idea why this is not working for me.
Few hours later I have read that removing the following lines will solve the problem, but nothing happened.
<bean id="viewMappings" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property value="true" name="alwaysUseFullPath"></property>
<property name="defaultHandler">
<bean class="org.springframework.web.servlet.mvc.UrlFilenameViewController" />
</property>
<property name="order" value="1"/>
</bean>
Also changing
<servlet-mapping>
<servlet-name>onlinecatalog</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
to
<servlet-mapping>
<servlet-name>onlinecatalog</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
did not help.