2. Spring Configuration

All of the Spring configuration files in the root directory of 'WEB-INF/spring' are loaded in the root Spring context.

This configuration is for loading anything web related into the root context, in this case it's just the web security.

WEB-INF/spring/web-context.xml
                
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans 
                           http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://www.springframework.org/schema/context 
                           http://www.springframework.org/schema/context/spring-context.xsd">

    <import resource="classpath:/META-INF/spring/web/web-security-context.xml"/>
    
</beans>
                
            

Most of the main Spring configuration files from the different modules are loaded. Basic security, marshallers, DB related code, and the services layer.

WEB-INF/spring/services-context.xml
                
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans 
                           http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://www.springframework.org/schema/context 
                           http://www.springframework.org/schema/context/spring-context.xsd">

    <import resource="classpath*:/META-INF/spring/security/**/*-context.xml"/>
    <import resource="classpath*:/META-INF/spring/marshaller/**/*-context.xml"/>
    <import resource="classpath*:/META-INF/spring/db/**/*-context.xml"/>
    <import resource="classpath*:/META-INF/spring/services/**/*-context.xml"/>

</beans>
                
            

The REST API servlet configuration loads the REST controllers and their views & handlers.

WEB-INF/spring/mvc/rest-servlet-context.xml
                
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans 
                           http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://www.springframework.org/schema/context 
                           http://www.springframework.org/schema/context/spring-context.xsd">

    <import resource="classpath*:/META-INF/spring/mvc/**/*-context.xml"/>
    <import resource="classpath:/META-INF/spring/web/web-rest-servlet-context.xml"/>
    
</beans>
                
            

The JSP servlet loads the JSP controllers and configures it's static and dynamic resources. Wild card mappings are setup to serve all resources for Sencha ExtJS & Sencha Touch.

Also a static content zip is generated. So if a server like Apache is proxying the servlet container, it could also be configured to serve the static content.

WEB-INF/spring/mvc/jsp-servlet-context.xml
                
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xsi:schemaLocation="http://www.springframework.org/schema/beans 
                           http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://www.springframework.org/schema/context 
                           http://www.springframework.org/schema/context/spring-context.xsd
                           http://www.springframework.org/schema/mvc
                           http://www.springframework.org/schema/mvc/spring-mvc.xsd">

    <context:component-scan base-package="org.springbyexample.contact.web.servlet.mvc" />

    <mvc:annotation-driven />
    
    <mvc:view-controller path="/index.html" />
    <mvc:view-controller path="/login.html" />
    <mvc:view-controller path="/logoutSuccess.html" />
    
    <mvc:resources mapping="/extjs/**" location="/extjs/" />
    <mvc:resources mapping="/touch/**" location="/touch/" />
    
    <bean id="tilesConfigurer"
          class="org.springframework.web.servlet.view.tiles2.TilesConfigurer"
          p:definitions="/WEB-INF/tiles-defs/templates.xml" />
 
    <bean id="tilesViewResolver"
          class="org.springframework.web.servlet.view.UrlBasedViewResolver"
          p:viewClass="org.springbyexample.web.servlet.view.tiles2.DynamicTilesView"
          p:prefix="/WEB-INF/jsp/"
          p:suffix=".jsp" />
    
    <!-- Declare the Interceptor -->
    <mvc:interceptors>    
        <bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"
              p:paramName="locale" />
    </mvc:interceptors>
    
    <!-- Declare the Resolver -->
    <bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver" />

</beans>