zoukankan      html  css  js  c++  java
  • <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

     

  • 相关阅读:
    div错位解决IE6、IE7、IE8样式不兼容问题
    DIV背景半透明文字不半透明的样式
    Div 自适应屏幕大小
    mysql 设置外键 四大属性 CASCADE SET NULL NO ACTION RESTRICT 理解
    msyql 主从配置
    全国最新区划数据-四级-省-市-县(区)-乡(镇)
    ThinkPHP3.2 伪静态配置
    色彩网站
    Javascript php 异常捕获
    jQuery 操作大全
  • 原文地址:https://www.cnblogs.com/mingluosunshan/p/4796119.html
Copyright © 2011-2022 走看看