include-filter和exclude-filter
最近仔细看看项目中的代码,发现一直在做项目,就是想着怎么去实现,剩下的东西基本都没注意看。结果到面试的时候我才发现这会是一件很悲剧的事情。所以痛定思痛,回过头来看看细节,只要现在开始,还不算晚.
<context:include-filter>和<context:exclude-filter>各代表引入和排除的過濾
<!-- 使用annotation 自动注册bean,并保证@Required,@Autowired的属性被注入 --><context:component-scan base-package="cn.tonyan.tonyan.web" ><context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/></context:component-scan>
<!-- 自动扫描且只扫描@Controller --><context:component-scan base-package="cn.tonyan.tonyan.web" use-default-filters="false"><context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/></context:component-scan>