Final decision based on @Nathan Bubna's suggestion .
The project is based on the Spring MVC pattern , with Maven controlled resources.
Spring version 3.1.1.RELEASE
/WEB-INF/web.xml
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/spring/root-context.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <servlet> <servlet-name>mainServlet</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>mainServlet</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> </web-app>
/WEB-INF/spring/servlet/servlet-context.xml
<?xml version="1.0" encoding="UTF-8"?> <beans:beans xmlns="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <annotation-driven /> <resources mapping="/resources/**" location="/resources/" /> <resources location="/resources/favicon.ico" mapping="/favicon.ico"/> <resources location="/resources/favicon.ico" mapping="/favicon.png"/> <beans:bean id="velocityConfig" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer"> <beans:property name="resourceLoaderPath" value="/WEB-INF/views/" /> </beans:bean> <beans:bean id="viewResolver" class="org.springframework.web.servlet.view.velocity.VelocityLayoutViewResolver"> <beans:property name="cache" value="true" /> <beans:property name="prefix" value="" /> <beans:property name="layoutUrl" value="layout.vm"></beans:property> <beans:property name="suffix" value=".vm" /> </beans:bean> <context:component-scan base-package="com.mypackage.subpackage" /> </beans:beans>
important pom.xml lines
<dependency> <groupId>org.apache.velocity</groupId> <artifactId>velocity</artifactId> <version>1.7</version> </dependency> <dependency> <groupId>org.apache.velocity</groupId> <artifactId>velocity-tools</artifactId> <version>2.0</version> </dependency>
source share