您的位置:首页 > 编程语言 > Java开发

【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的配置文件分开配置。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: