<mvc:annotation-driven>

1.<mvc:annotation-driven>作用:
注册了HandlerMapping,HandlerAdapter,HandlerExceptionResolver;比如:自动加载RequestMappingHandlerMapping和RequestMappingHandlerAdapter,在springmvc.xml配置文件中使用<mvc:annotation-driven>替代注解处理器和适配器的配置。
帮助文档:

/**
 * A {@link BeanDefinitionParser} that provides the configuration for the
 * {@code <annotation-driven/>} MVC namespace  element.
 *
 * <p>This class registers the following {@link HandlerMapping}s:</p>
 * <ul>
 *  <li>{@link RequestMappingHandlerMapping}
 *  ordered at 0 for mapping requests to annotated controller methods.
 *  <li>{@link BeanNameUrlHandlerMapping}
 *  ordered at 2 to map URL paths to controller bean names.
 * </ul>
 *
 * <p><strong>Note:</strong> Additional HandlerMappings may be registered
 * as a result of using the {@code <view-controller>} or the
 * {@code <resources>} MVC namespace elements.
 *
 * <p>This class registers the following {@link HandlerAdapter}s:
 * <ul>
 *  <li>{@link RequestMappingHandlerAdapter}
 *  for processing requests with annotated controller methods.
 *  <li>{@link HttpRequestHandlerAdapter}
 *  for processing requests with {@link HttpRequestHandler}s.
 *  <li>{@link SimpleControllerHandlerAdapter}
 *  for processing requests with interface-based {@link Controller}s.
 * </ul>
 *
 * <p>This class registers the following {@link HandlerExceptionResolver}s:
 * <ul>
 *  <li>{@link ExceptionHandlerExceptionResolver} for handling exceptions
 *  through @{@link ExceptionHandler} methods.
 *  <li>{@link ResponseStatusExceptionResolver} for exceptions annotated
 *  with @{@link ResponseStatus}.
 *  <li>{@link DefaultHandlerExceptionResolver} for resolving known Spring
 *  exception types
 * </ul>
 *
 * <p>Both the {@link RequestMappingHandlerAdapter} and the
 * {@link ExceptionHandlerExceptionResolver} are configured with instances of
 * the following by default:
 * <ul>
 *  <li>A {@link ContentNegotiationManager}
 *  <li>A {@link DefaultFormattingConversionService}
 *  <li>A {@link LocalValidatorFactoryBean} if a JSR-303 implementation is
 *  available on the classpath
 *  <li>A range of {@link HttpMessageConverter}s depending on what 3rd party
 *  libraries are available on the classpath.
 * </ul>
 *
 * @author Keith Donald
 * @author Juergen Hoeller
 * @author Arjen Poutsma
 * @author Rossen Stoyanchev
 * @since 3.0
 */

2.标签解析过程:
1)在spring-webmvc的jar包中的/META-INF/spring.handlers中定义了mvc标签和对应的处理器:

http\://www.springframework.org/schema/mvc=org.springframework.web.servlet.config.MvcNamespaceHandler

2)在处理器中注册annotation-driven

registerBeanDefinitionParser("annotation-driven", new AnnotationDrivenBeanDefinitionParser());
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值