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的几个组件的原因。

  • 相关阅读:
    精通特征工程
    reduce_mem_usage 降低内存使用 绘制学习率曲线和验证曲线
    正态性检验 Python正态性检验
    pd.melt Pandas 的melt的使用
    pandas dataframe 格式设置 set_option
    常用模块
    第9章 列表生成式、生成器和迭代器
    全栈作业(一)
    第8章 装饰器、模块和包
    第7章 Python 函数
  • 原文地址:https://www.cnblogs.com/chengxuxiaoyuan/p/15752632.html
Copyright © 2011-2022 走看看