<mvc:annotation-driven /><context:annotation-config/><context:component-scan/>
2015-09-09 22:01
513 查看
[b]<context:annotation-config/>[/b]
隐式地向 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
我们使用注解时一般都会配置扫描包路径选项:
该配置项其实也包含了自动注入上述processor的功能,因此当使用<context:component-scan/>后,即可将<context:annotation-config/>省去。
有了[b]<context:component-scan>[/b],另一个<context:annotation-config/>标签根本可以移除掉,因为已经被包含进去了。
<context:component-scan>提供两个子标签:<context:include-filter>和<context:exclude-filter>各代表引入和排除的过滤。
[b]<mvc:annotation-driven />[/b]
<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
隐式地向 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/>省去。
有了[b]<context:component-scan>[/b],另一个<context:annotation-config/>标签根本可以移除掉,因为已经被包含进去了。
<context:component-scan>提供两个子标签:<context:include-filter>和<context:exclude-filter>各代表引入和排除的过滤。
[b]<mvc:annotation-driven />[/b]
<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
相关文章推荐
- 多CPU与单CPU的spin_lock使用上的区别
- -force_load (加载静态库崩溃)
- FindBugs 入门——帮你减少代码中的bug数
- mac常用shell命令
- Apache Spark 1.5新特性介绍
- Android实例-操作sqlite数据库之Grid显示图片(XE8+小米2)
- nyoj 1185 最大最小值【线段树最大值最小值维护】
- Adobe Photoshop CS6学习要点
- poj1083
- Android—软键盘弹出时关于布局的问题
- OC08_字典Dictionary
- 双目相机的一个例子
- 代码检查、代码走查与评审
- Openstack部署总结:“部署过程Error: Local ip for ovs agent must be set when tunneling is enabled”问题
- js中SetInterval与setTimeout用法
- Spark 1.4新特性概述
- lintcode-最小路径和-110
- 使用GCE(Google Container Engine)体验容器云服务 (1)
- 自然界的目的,更深层次的密码以及未知的灾难----读《三体》第一部第三节
- Android(java)学习笔记219:开发一个多界面的应用程序之两种意图