• <mvc:annotation-driven /><context:annotation-config/><context:component-scan/>


    <context:annotation-config/>

    隐式地向 Spring容器注册AutowiredAnnotationBeanPostProcessor、 RequiredAnnotationBeanPostProcessor、CommonAnnotationBeanPostProcessor以及 PersistenceAnnotationBeanPostProcessor这4个BeanPostProcessor

    1、使用@Autowired注解,那么就必须事先在 Spring 容器中声明 AutowiredAnnotationBeanPostProcessor Bean

    <bean class="org.springframework.beans.factory.annotation. AutowiredAnnotationBeanPostProcessor "/>

    2、使用@ Resource @ PostConstruct@ PreDestroy等注解就必须声明CommonAnnotationBeanPostProcessor

    3、使用@PersistenceContext注解,就必须声明PersistenceAnnotationBeanPostProcessor

    4、使用@Required的注解,就必须声明RequiredAnnotationBeanPostProcessor

     我们使用注解时一般都会配置扫描包路径选项:

    <context:component-scan base-package="pack.pack"/>

      该配置项其实也包含了自动注入上述processor的功能,因此当使用<context:component-scan/>后,即可将<context:annotation-config/>省去。

    有了<context:component-scan>,另一个<context:annotation-config/>标签根本可以移除掉,因为已经被包含进去了。

    <context:component-scan>提供两个子标签:<context:include-filter>和<context:exclude-filter>各代表引入和排除的过滤。

    <mvc:annotation-driven />

    <mvc:annotation-driven /> 会自动注册DefaultAnnotationHandlerMapping与AnnotationMethodHandlerAdapter 两个bean,是spring MVC为@Controllers分发请求所必须的。
    并提供了:数据绑定支持,@NumberFormatannotation支持,@DateTimeFormat支持,@Valid支持,读写XML的支持(JAXB),读写JSON的支持(Jackson)。

    HandlerMapping接口 -- 处理请求的映射

    HandlerMapping接口的实现类:

    SimpleUrlHandlerMapping  通过配置文件,把一个URL映射到Controller

    DefaultAnnotationHandlerMapping  通过注解,把一个URL映射到Controller类上

     

    HandlerAdapter接口 -- 处理请求的映射

    AnnotationMethodHandlerAdapter类,通过注解,把一个URL映射到Controller类的方法上

     

    http://blog.chinaunix.net/uid-20586655-id-3000946.html

     

  • 相关阅读:
    线程池参数详解
    线程池各个参数详解以及如何自定义线程池
    fastdfs 安装
    SQL 执行顺序
    《SQL 进阶教程》 查找局部不一致的数据
    redis 高性能的原因
    一致性hash
    环境部署数据库报错
    redis 常用命令
    redis 高级学习和应用场景
  • 原文地址:https://www.cnblogs.com/mingluosunshan/p/4796119.html
Copyright © 2020-2023  润新知