springmvc-servlet.xml中use-default-filters的作用
1、<!-- 启用注解扫描,并定义组件查找规则 ,mvc层只负责扫描@Controller -->
- <context:component-scan base-package="com.nn.web.controller"
- use-default-filters="false">
- <context:include-filter type="annotation"
- expression="org.springframework.stereotype.Controller" />
- </context:component-scan>
2、在context:component-scan可以添加use-default-filters,spring配置中的use-default-filters用来指示是否自动扫描带有@Component、@Repository、@Service和@Controller的类。默认为true,即默认扫描。
3、如果想要过滤其中这四个注解中的一个,比如@Repository,可以添加<context:exclude-filter />子标签:
- <context:component-scan base-package="tv.crm" scoped-proxy="targetClass" use-default-filters="true">
- <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Repository"/>
- </context:component-scan>
4、而<context:include-filter/>子标签是用来添加扫描注解的。
- <context:component-scan base-package="tv.crm" scoped-proxy="targetClass" use-default-filters="false">
- <context:include-filter type="annotation" expression="org.springframework.stereotype.Repository"/>
- </context:component-scan>
5、但是如果添加和排除的是相同,则必须include-filter在前,exclude-filter在后,否则配置不符合spring -context-3.0.xsd要求,Spring容器解析时会出错。上面的配置会把@Repository注解的类排除掉。
- <span style="font-size:18px;"><context:component-scan base-package="tv.crm" scoped-proxy="targetClass" use-default-filters="false">
- <context:include-filter type="annotation" expression="org.springframework.stereotype.Repository"/>
- <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Repository"/>
- </context:component-scan></span>
springmvc-servlet.xml中use-default-filters的作用的更多相关文章
- SpringMVC: web.xml中声明DispatcherServlet时一定要加入load-on-startup标签
游历SpringMVC源代码后发现,在web.xml中注冊的ContextLoaderListener监听器不过初始化了一个根上下文,只完毕了组件扫描和与容器初始化相关的一些工作,并没有探測到详细每一 ...
- SpringMVC: web.xml中声明DispatcherServlet时一定要添加load-on-startup标签
游历SpringMVC源码后发现,在web.xml中注册的ContextLoaderListener监听器只是初始化了一个根上下文,仅仅完成了组件扫描和与容器初始化相关的一些工作,并没有探测到具体每个 ...
- Tomcat配置文件之servlet.xml中选项介绍
Servlet.xml 分为以下元素: server, service, Connector ( 表示客户端和service之间的连接), Engine ( 表示指定service 中的请求处理机,接 ...
- ()-servlet.xml中剥离出的hibernate.cfg.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...
- web.xml中<welcome-file-list>标签不起作用
之前也都提到过,web.xml会通过<servlet>和<servlet-mapping>来确定url和指定contoller文件,乃至于jsp页面的联系. 但是有一个< ...
- web.xml中的welcome-file-list不起作用
今天尝试使用struts2+ urlrewrite+sitemesh部署项目,结果发现welcome-file-list中定义的欢迎页不起作用: <welcome-file-list> & ...
- maven pom.xml 中各个标签元素的作用
<groupId> : 项目或者组织的唯一标识 <artifactId>项目的通用名称 <artifactId>项目的通用名称 <version> 项目 ...
- SpringMVC(十六):如何使用编程方式替代/WEB-INF/web.xml中的配置信息
在构建springmvc+mybatis项目时,更常用的方式是采用web.xml来配置,而且一般情况下会在web.xml中使用ContextLoaderListener加载applicationCon ...
- 【Servlet】web.xml中welcome-file-list的作用
今天尝试使用struts2+ urlrewrite+sitemesh部署项目,结果发现welcome-file-list中定义的欢迎页不起作用: <welcome-file-list> & ...
- web.xml中welcome-file-list的作用
今天尝试使用struts2+ urlrewrite+sitemesh部署项目,结果发现welcome-file-list中定义的欢迎页不起作用: <welcome-file-list> & ...
随机推荐
- Revit API取得全部元素
; ; ; ; } ; } ; } TaskDialog ...
- delphi:临界区对象TCriticalSection(Delphi) 与 TRtlCriticalSection 的区别
临界区对象TCriticalSection(Delphi) 与 TRtlCriticalSection 的区别 TRtlCriticalSection 是一个结构体,在windows单元中定义: 是I ...
- MyEclipse10安装Log4E插件
一. Log4E插件下载 下载地址:http://log4e.jayefem.de/content/view/3/2/ 二.安装Log4E插件 将下载下来的压缩包解压缩,如下图所示: 解压缩生成的[d ...
- After 2 years, I have finally solved my "Slow Hyper-V Guest Network Performance" issue. I am ecstatic.
Edit - It should be known that I was initially researching this issue back in 2012 and the solution ...
- mac 刻录ISO系统盘
今天本本系统坏了,手头上又没有U盘PE工具,只有MAC和光驱,只好在MAC上下载系统ISO刻录,我是直接点ISO文件,右键刻录到光盘,刻录好之后放到本本上发现不能引导,再把光盘放回MAC上一看,光盘里 ...
- 关于云计算基础架构IaaS层的几点看法
真实的云计算什么样? 云计算对普通用户来说,总是一个云里雾里的话题. 本文从最基础的概念開始科普,说明了四个常见的错误理解,和作者的四个猜想. IaaS(Infrastructure as a Ser ...
- 为什要使用预编译SQL?(转)
本文转自https://www.cnblogs.com/zouqin/p/5314827.html 今天在研发部技术大牛的指点下,我终于明白了为什么要使用SQL预编译的形式执行数据库JDBC:
- Glibc 和 uClibc
转自:https://blog.csdn.net/clirus/article/details/50145959?locationNum=4 最近在搞mips openwrt框架的东西,mipc的GC ...
- MySql错误处理(三)- 错误处理的例子
有几种错误处理的声明形式: § 如果任何错误(不是 NOT FOUND ) , 设置 l_error 为 1 后继续执行: DECLARE CONTINUE HANDLER FOR SQLEXCEPT ...
- java swing MenuItem乱码处理
用java开发一个带有托盘图标的程序, 其它模块的中文显示都是正常的,就只有托盘中点击小图标时弹出的菜单中的中文是方框(中文方块) 解决: 1: 在你的具有main函数的类也即你应用运行的主类上点击右 ...







