include-filter和exclude-filter
2016-03-07 18:13
531 查看
Spring学习中,遇到问题记录下,与大家分享,如有不对的地方还请多多指教。
在父容器中(applicationContext.xml)
在子容器spring-mvc.xml中
这样配置的原因是因为Spring会用到springmvc.xml 所以就会有父子容器的概念了.applicationcontext.xml是父容器,而springmvc.xml是子容器.在父容器中排除不扫描,在子容器中扫描,这样就避免了冲突。
Controller会进步前辈行扫描装配,而此时的Service还没有进行事务的加强处理,获得的将是原样的Service(没有经过事务加强处理) ,最后才是applicationContext.xml中的扫描设备进行事务处理。
<context:include-filter>和<context:exclude-filter>各代表引入和排除的的过滤。
在父容器中(applicationContext.xml)
<context:component-scan base-package="com.coamctech.eastlending"> <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" /> <context:exclude-filter type="annotation" expression="org.springframework.web.bind.annotation.ControllerAdvice" /> </context:component-scan>
在子容器spring-mvc.xml中
<!-- 自动扫描且只扫描@Controller --> <context:component-scan base-package="com.coamctech.eastlending" use-default-filters="false"> <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" /> <context:include-filter type="annotation" expression="org.springframework.web.bind.annotation.ControllerAdvice" /> </context:component-scan>
这样配置的原因是因为Spring会用到springmvc.xml 所以就会有父子容器的概念了.applicationcontext.xml是父容器,而springmvc.xml是子容器.在父容器中排除不扫描,在子容器中扫描,这样就避免了冲突。
Controller会进步前辈行扫描装配,而此时的Service还没有进行事务的加强处理,获得的将是原样的Service(没有经过事务加强处理) ,最后才是applicationContext.xml中的扫描设备进行事务处理。
相关文章推荐
- 一个jar包里的网站
- 一个jar包里的网站之文件上传
- 一个jar包里的网站之返回对媒体类型
- Spring整合Quartz(JobDetailBean方式)
- Spring整合Quartz(JobDetailBean方式)
- Ruby中require、load、include、extend的区别介绍
- vbscript include的办法实现代码第1/2页
- 解析C++编程中的#include和条件编译
- PHP脚本中include文件出错解决方法
- Flex include和import ActionScript代码
- set_include_path在win和linux下的区别
- php include加载文件两种方式效率比较
- How to Auto Include a Javascript File
- 浅谈ASP.NET的include的使用方法
- java/jsp中 中文问题详解
- php相对当前文件include其它文件的方法
- JSP计数器的制作
- 模拟Spring的简单实现
- spring+html5实现安全传输随机数字密码键盘
- Spring中属性注入详解