From bfd61d6303a4254e5c3b869b468545f29dfefe42 Mon Sep 17 00:00:00 2001 From: Keith Donald Date: Wed, 10 Feb 2010 20:16:38 +0000 Subject: [PATCH] mvc namespace docs --- spring-framework-reference/src/mvc.xml | 110 +++++++++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/spring-framework-reference/src/mvc.xml b/spring-framework-reference/src/mvc.xml index fbe7047a32e..e28553c017e 100644 --- a/spring-framework-reference/src/mvc.xml +++ b/spring-framework-reference/src/mvc.xml @@ -3119,7 +3119,117 @@ public class SimpleController { <servlet-name>petclinic</servlet-name> </filter-mapping> +
+ Configuring Spring MVC + + Spring 3 introduces a mvc XML configuration namespace that simplifies the setup of Spring MVC inside your web application. + Instead of registering low-level beans such as AnnotationMethodHandlerAdapter, you can simply use the namespace and its higher-level constructs. + This is generally preferred unless you require finer-grained control of the configuration at the bean level. + + + The mvc namespace consists of three tags: mvc:annotation-driven, mvc:interceptors, and mvc:view-controller. + Each of these tags is documented below and in the XML schema. + +
+ mvc:annotation-driven + + This tag registers the DefaultAnnotationHandlerMapping and AnnotationMethodHandlerAdapter beans that are required for Spring MVC to dispatch requests to @Controllers. + The tag configures those two beans with sensible defaults based on what is present in your classpath. + The defaults are: + + + + Support for Spring 3's Type ConversionService in addition to JavaBeans PropertyEditors during Data Binding. + A ConversionService instance produced by the org.springframework.format.support.FormattingConversionServiceFactoryBean is used by default. + This can be overriden by setting the conversion-service attribute. + + + + + Support for formatting Number fields using the @NumberFormat annotation + + + + + Support for formatting Date, Calendar, Long, and Joda Time fields using the @DateTimeFormat annotation, if Joda Time is present on the classpath. + + + + + Support for validating @Controller inputs with @Valid, if a JSR-303 Provider is present on the classpath. + The validation system can be explicitly configured by setting the validator attribute. + + + + + Support for reading and writing XML, if JAXB is present on the classpath. + + + + + Support for reading and writing JSON, if Jackson is present on the classpath. + + + + A typical usage is shown below: + + + + + +]]> + + +
+
+ mvc:interceptors + + This tag allows you to register custom HandlerInterceptors or WebRequestInterceptors that should be applied to all HandlerMapping beans. + You can also restrict the URL paths specifc interceptors apply to. + + + An example of registering an interceptor applied to all URL paths: + + + +]]> + + + An example of registering an interceptor limited to a specific URL path: + + + + + + +]]> + +
+
+ mvc:view-controller + + This tag is a shorcut for defining a ParameterizableViewController that immediately forwards to a view when invoked. + Use it in static cases when there is no Java Controller logic to execute before the view generates the response. + + + An example of view-controller that forwards to a home page is shown below: + + ]]> + +
+
More Spring Web MVC Resources