public final class

MvcAnnotationDriven

extends AbstractFeatureSpecification
java.lang.Object
   ↳ org.springframework.context.config.AbstractFeatureSpecification
     ↳ org.springframework.web.servlet.config.MvcAnnotationDriven

Class Overview

Specifies the Spring MVC "annotation-driven" container feature. The feature provides the following fine-grained configuration:

  • DefaultAnnotationHandlerMapping bean for mapping HTTP Servlet Requests to @Controller methods using @RequestMapping annotations.
  • AnnotationMethodHandlerAdapter bean for invoking annotated @Controller methods.
  • HandlerExceptionResolver beans for invoking @ExceptionHandler controller methods and for mapping Spring exception to HTTP status codes.

The HandlerAdapter is further configured with the following, which apply globally (across controllers invoked though the AnnotationMethodHandlerAdapter):

Summary

[Expand]
Inherited Fields
From class org.springframework.context.config.AbstractFeatureSpecification
Public Constructors
MvcAnnotationDriven()
Creates an MvcAnnotationDriven specification.
Public Methods
MvcAnnotationDriven argumentResolvers(WebArgumentResolver... resolvers)
MvcAnnotationDriven conversionService(String conversionService)

The ConversionService to use for type conversion during field binding.

MvcAnnotationDriven conversionService(ConversionService conversionService)

The ConversionService bean instance to use for type conversion during field binding.

MvcAnnotationDriven messageCodesResolver(String messageCodesResolver)
The MessageCodesResolver to use to build message codes from data binding and validation error codes.
MvcAnnotationDriven messageCodesResolver(MessageCodesResolver messageCodesResolver)
The MessageCodesResolver to use to build message codes from data binding and validation error codes.
MvcAnnotationDriven messageConverters(HttpMessageConverter...<?> converters)
The HttpMessageConverter types to use for converting @RequestBody method parameters and @ResponseBody method return values.
MvcAnnotationDriven shouldRegisterDefaultMessageConverters(boolean shouldRegister)
Indicates whether or not default HttpMessageConverter registrations should be added in addition to the ones provided via messageConverters(HttpMessageConverter)
MvcAnnotationDriven validator(Validator validator)
The Validator bean instance to use to validate Controller model objects.
MvcAnnotationDriven validator(String validator)
The Validator bean instance to use to validate Controller model objects.
Protected Methods
void doValidate(ProblemCollector problems)
[Expand]
Inherited Methods
From class org.springframework.context.config.AbstractFeatureSpecification
From class java.lang.Object
From interface org.springframework.context.config.FeatureSpecification
From interface org.springframework.context.config.SourceAwareSpecification

Public Constructors

public MvcAnnotationDriven ()

Creates an MvcAnnotationDriven specification.

Public Methods

public MvcAnnotationDriven argumentResolvers (WebArgumentResolver... resolvers)

public MvcAnnotationDriven conversionService (String conversionService)

The ConversionService to use for type conversion during field binding. This is an alternative to conversionService(ConversionService) allowing you to provide a bean name rather than a bean instance.

Parameters
conversionService the ConversionService bean name

public MvcAnnotationDriven conversionService (ConversionService conversionService)

The ConversionService bean instance to use for type conversion during field binding. This is not required input. It only needs to be provided explicitly if custom converters or formatters need to be configured.

If not provided, a default FormattingConversionService is registered that contains converters to/from standard JDK types. In addition, full support for date/time formatting will be installed if the Joda Time library is present on the classpath.

Parameters
conversionService the ConversionService instance to use

public MvcAnnotationDriven messageCodesResolver (String messageCodesResolver)

The MessageCodesResolver to use to build message codes from data binding and validation error codes. This is an alternative to messageCodesResolver(MessageCodesResolver) allowing you to provide a bean name rather than a bean instance.

Parameters
messageCodesResolver the MessageCodesResolver bean name

public MvcAnnotationDriven messageCodesResolver (MessageCodesResolver messageCodesResolver)

The MessageCodesResolver to use to build message codes from data binding and validation error codes. This is not required input. If not specified the DefaultMessageCodesResolver is used.

Parameters
messageCodesResolver the MessageCodesResolver bean instance

public MvcAnnotationDriven messageConverters (HttpMessageConverter...<?> converters)

The HttpMessageConverter types to use for converting @RequestBody method parameters and @ResponseBody method return values. HttpMessageConverter registrations provided here will take precedence over HttpMessageConverter types registered by default. Also see shouldRegisterDefaultMessageConverters(boolean) if default registrations are to be turned off altogether.

Parameters
converters the message converters

public MvcAnnotationDriven shouldRegisterDefaultMessageConverters (boolean shouldRegister)

Indicates whether or not default HttpMessageConverter registrations should be added in addition to the ones provided via messageConverters(HttpMessageConverter)

Parameters
shouldRegister true will result in registration of defaults.

public MvcAnnotationDriven validator (Validator validator)

The Validator bean instance to use to validate Controller model objects. This is not required input. It only needs to be specified explicitly if a custom Validator needs to be configured.

If not specified, JSR-303 validation will be installed if a JSR-303 provider is present on the classpath.

Parameters
validator the Validator bean instance

public MvcAnnotationDriven validator (String validator)

The Validator bean instance to use to validate Controller model objects. This is an alternative to validator(Validator) allowing you to provide a bean name rather than a bean instance.

Parameters
validator the Validator bean name

Protected Methods

protected void doValidate (ProblemCollector problems)