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

spring-mvc注解配置小记

2017-12-20 11:57 281 查看
Controller中注解Service时,Service的实现类需加@Service,dao的实现类需加@Repository。

另:配置文件中对应的包也需要扫描到!!!

<context:annotation-config /><!-- 启动注解 -->
<!--上下文组件扫描 包 *通配 -->
<context:component-scan base-package="cxweb.*" />

还有一个很重要。容易被忽略的:

web.xml配置中还需要加上2个监听器(顺序有要求!):

<listener>
<listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

以上就是spring-mvc注解配置时需要非常注意的地方,不然Controller中注解Service时注解不进来,注解不进来!!!!!!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: