【SpringMVC】<context:include-filter>和<context:exclude-filter>
2016-03-07 21:39
525 查看
ApplicationContext.xml和spring-mvc.xml分开配置,各司其职。
在ApplicationContext.xml中配置:
<context:component-scan base-package="com.practise">
<context:exclude-filter type="regex" expression="com.practise.controller"/>
</context:component-scan>
如果配置了<context:component-scan>那么<context:annotation-config/>标签就可以不用再xml中配置了,因为前者包含了后者。
其中,<context:exclude-filter>的type可以为下面的值:</pre></p><p>annotatioin: 标识了某个annotation的类。例如,<span style="background-color: rgb(240, 240, 240);"><context:exclude-filter type="regex" expression="</span><span style="color: rgb(0, 0, 255);">org.springframework.stereotype.Controller</span><span style="background-color: rgb(240, 240, 240);">"/>.</span></p><p>regre: 匹配类全名的正则表达式。</p><p>assignable:a class (or interface) that the target components are assignable to (extend/implement)。</p><p>assignable:an AspectJ type pattern expression to be matched by the target components。</p><p>assignable:a custom implementation of the org.springframework.core.type.TypeFilter interface。</p><p></p><p>在spring-mvc.xml中配置:</p><p><pre name="code" class="html"><context:component-scan base-package="com.practise.controller" />
同时,也可以将properties的配置文件分开配置。
在ApplicationContext.xml中配置:
<context:component-scan base-package="com.practise">
<context:exclude-filter type="regex" expression="com.practise.controller"/>
</context:component-scan>
如果配置了<context:component-scan>那么<context:annotation-config/>标签就可以不用再xml中配置了,因为前者包含了后者。
其中,<context:exclude-filter>的type可以为下面的值:</pre></p><p>annotatioin: 标识了某个annotation的类。例如,<span style="background-color: rgb(240, 240, 240);"><context:exclude-filter type="regex" expression="</span><span style="color: rgb(0, 0, 255);">org.springframework.stereotype.Controller</span><span style="background-color: rgb(240, 240, 240);">"/>.</span></p><p>regre: 匹配类全名的正则表达式。</p><p>assignable:a class (or interface) that the target components are assignable to (extend/implement)。</p><p>assignable:an AspectJ type pattern expression to be matched by the target components。</p><p>assignable:a custom implementation of the org.springframework.core.type.TypeFilter interface。</p><p></p><p>在spring-mvc.xml中配置:</p><p><pre name="code" class="html"><context:component-scan base-package="com.practise.controller" />
同时,也可以将properties的配置文件分开配置。
相关文章推荐
- Java中的对象,包,类
- Java中“==”与equals方法的区别
- [疯狂Java]AWT:右键菜单
- spring的一个小例子(二)--解析前面的小例子
- java的static块执行时机
- Spring mvc+mybatis框架下的TooManyResultsException异常
- leetcode:Sum Root to Leaf Numbers 【Java】
- java第一周学习总结
- [JAVA · 初级]:6.特殊关键字:this
- javaWeb poi导入excel文件
- Java源码阅读之ArrayList
- 2016蓝桥杯假期任务之《翻硬币 》
- 《Java实战开发经典》第六章6.3
- java中的sleep()和wait()的区别
- Java命名规范
- java类加载器
- java int,string,char三种类型变量之间的互相转换
- Netbeans jdkhome 配置
- 二叉树的镜像
- 公共技术点之 Java 注解 Annotation