Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-6306

Add mvc namespace for simplifying setup of Spring MVC

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.0 RC1
    • Fix Version/s: 3.0 RC2
    • Component/s: Web
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      Spring MVC setup could be simplified considerably by adding a custom XML namespace. A simple tag to configure <mvc:annotated-controllers/> with reasonable default settings would be a great start.

      Example benefits:

      AFTER MVC NAMESPACE

      <?xml version="1.0" encoding="UTF-8"?>
      <beans xmlns="http://www.springframework.org/schema/beans"
          xmlns:mvc="http://www.springframework.org/schema/mvc"
      	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
      		http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
      
      	<mvc:annotation-driven/>
      	
      </beans>
      
      

      BEFORE MVC NAMESPACE

      <?xml version="1.0" encoding="UTF-8"?>
      <beans xmlns="http://www.springframework.org/schema/beans"
      	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      	xsi:schemaLocation="
      		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
      
      	<!-- HANDLER MAPPING RULES -->
      	
      	<!-- Maps requests to @Controllers based on @RequestMapping("path") annotation values
      		 If no annotation-based path mapping is found, Spring MVC sends a 404 response and logs a pageNotFound warning. -->
      	<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
      		<property name="order" value="1" />
      	</bean>
      	
      	<!-- REGISTERED HANDLER TYPES -->
      
      	<!-- Enables annotated @Controllers; responsible for invoking an annotated POJO @Controller when one is mapped. -->
      
      	<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
      		<!-- Configures Spring MVC DataBinder instances globally -->
      		<property name="webBindingInitializer">
      			<bean class="org.springframework.web.bind.support.ConfigurableWebBindingInitializer">
      				<property name="conversionService" ref="conversionService" />
      				<property name="validator" ref="validator" />
      			</bean>
      		</property>
      	</bean>
      
      	<!-- FIELD TYPE CONVERSION AND VALIDATION -->
      	
      	<!-- Enables the Spring 3 Type Conversion system that uses Joda Time Formatting for Date/Time types -->
      	<bean id="conversionService" class="org.springframework.samples.petclinic.util.PetclinicConversionServiceFactory" />
      	
      	<!-- Configures JSR-303 Declarative Validation with default provider on classpath (Hibernate Validator) -->
      	<bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" />
      	
      </beans>
      
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                kdonald Keith Donald
                Reporter:
                kdonald Keith Donald
                Last updater:
                Trevor Marshall
              • Votes:
                1 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  8 years, 26 weeks ago