spring mvc和spring需要结合吗

spring mvc和spring需要结合吗


陪伴而非守候
浏览 613回答 1
1回答

紫衣仙女

1.在springmvc配置文件中扫描bean的时候。只扫描包含@controller。因为既然要和spring整合,那么springmvc还是专心做web请求的转发吧。2.在spring配置文件中去掉@controller的扫描。其他bean都是单例的,在容器启动的时候,一起初始花了。最后,其实单独使用 springmvc也是可以的。让他管理所有bean.1 在主容器中(applicationContext.xml),将Controller的注解打消掉[html] viewplaincopy<context:component-scan base-package="com"><context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" /></context:component-scan>2 而在springMVC配置文件中将Service注解给去掉[html] viewplaincopy<context:component-scan base-package="com"><context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" /><context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service" /></context:component-scan>
打开App,查看更多内容
随时随地看视频慕课网APP