2. Spring Configuration

The DefaultAnnotationHandlerMapping and AnnotationMethodHandlerAdapter beans are defined to process beans with @RequestMapping. The context:component-scan registers GenericController and PersonController, which are the two controllers defined in the org.springbyexample.web.servlet.mvc.simpleForm package. The tilesConfigurer bean configures tiles and dynamicTilesViewResolver takes the url of a request and uses it for the body in a Tiles template. The last three beans configure locale and messsage resource handling.

/WEB-INF/simple-form-servlet.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: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">

    <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
        <property name="interceptors" ref="localeChangeInterceptor"/>
    </bean>
    <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />

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

    <bean id="tilesConfigurer"
          class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
        <property name="definitions">
            <list>
                <value>/WEB-INF/tiles-defs/templates.xml</value>
            </list>
        </property>
    </bean>

    <bean id="dynamicTilesViewResolver"
          class="org.springframework.web.servlet.view.UrlBasedViewResolver">
        <property name="viewClass" value="org.springbyexample.web.servlet.view.tiles2.DynamicTilesView" />
        <property name="prefix" value="/WEB-INF/jsp/" />
        <property name="suffix" value=".jsp" />
    </bean>

    <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
        <property name="basenames">
            <value>messages</value>
        </property>
    </bean>
    
    <!-- Declare the Interceptor -->
    <bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
        <property name="paramName" value="locale"/>
    </bean>
    
    <!-- Declare the Resolver -->
    <bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver"/>

</beans>