前言
- 配置springmvc和spring的xml文件
- 加载顺序 : 先 exclude-filter,再到include-filter。
具体配置
- 在springmvc.xml中
<!-- 只扫描Controller -->
<context:component-scan base-package="com.hyq.controller" use-default-filters="false">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
在springContext-service.xml中
<!-- 自动扫描装配 排除controller 由mvc那边扫描--> <context:component-scan base-package="com.hyq"> <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/> </context:component-scan>