zoukankan      html  css  js  c++  java
  • mvc:annotationdriven标签的解析

    mvc:annotation-driven标签的解析

    一、概述

    spring中像mvc:annotation-driven这样的命名空间标签的解析都是通过BeanDefinitionParser接口的实现类进行解析的,该接口中有一个parse方法,处理逻辑就在每个实现类的这个方法中。

    mvc:annotation-driven标签的解析是通过 org.springframework.web.servlet.config.AnnotationDrivenBeanDefinitionParser这个类来解析的。

    二、AnnotationDrivenBeanDefinitionParser类注释解读

    A {@link BeanDefinitionParser} that provides the configuration for the
     * {@code <annotation-driven/>} MVC namespace element.
    

    这个类是用来解析springmvc配置文件中的mvc:annotation-driven标签的,通过解读类上的注释,可以看出这个类中主要给springmvc的容器中加入了如下的bean。

    RequestMappingHandlerMapping 用来把请求路径和@RequestMapping注解修饰的方法关联起来

    BeanNameUrlHandlerMapping 用来把请求路径和controller类型的bean映射起来

    RequestMappingHandlerAdapter

    HttpRequestHandlerAdapter

    SimpleControllerHandlerAdapter

    还有几个异常处理的bean

    ExceptionHandlerExceptionResolver
    ResponseStatusExceptionResolver
    DefaultHandlerExceptionResolver

    具体的可以从注释中看到

    这就是为什么在springmvc的配置文件中加了这个标签就可以自动配置spring的几个组件的原因。

  • 相关阅读:
    允许电脑被远程连接
    电脑更改用户密码
    HTML ------- 对文本进行操作的元素
    货币的发展
    SQL-----数据库三种删除方式详解
    HTML -------- 标签、元素、属性,
    HTML -------- 简介
    SQL --------------- HAVING 子句
    SQL --------------- GROUP BY 函数
    Shell编程——运算符
  • 原文地址:https://www.cnblogs.com/chengxuxiaoyuan/p/15752632.html
Copyright © 2011-2022 走看看