Joyen.fu
日中则昃,月盈则食。

<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

 

 

posted on 2015-09-09 22:01  Joyen.fu  阅读(383)  评论(0编辑  收藏  举报