关于Spring mvc 不会滚的问题

博客Markdown编辑器上线啦那些年我们追过的Wrox精品红皮计算机图书PMBOK第五版精讲视频教程火星人敏捷开发1001问

关于Spring mvc 不会滚的问题

分类:J2EE

配置都是正常的配置

我就不贴出来了

关键在于 service 包的自动注入

一定要放在父容器中扫描,否则事务不能回滚

所谓 父容器

Spring 和 spring mvc 有点区别

简单的讲 spring是父容器

spring mvc是子容器(可能不太合适)

也就是说

<!– service包(自动注入) –><context:component-scan base-package="demo.service" />

要放在applicationContext.xml中 如果放在springmvc.xml中 事务就会有问题 service不是父容器扫描出来的 事务不会回滚

<welcome-file-list><welcome-file>index.jsp</welcome-file> </welcome-file-list><context-param><param-name>contextConfigLocation</param-name><param-value>classpath:/config/applicationContext.xml</param-value> <!– 父容器 –> </context-param> <filter><description>字符集过滤器</description><filter-name>encodingFilter</filter-name><filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class><init-param><description>字符集编码</description><param-name>encoding</param-name><param-value>UTF-8</param-value></init-param> </filter> <filter-mapping><filter-name>encodingFilter</filter-name><url-pattern>/*</url-pattern> </filter-mapping> <listener><description>spring监听器</description><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <listener><listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class> </listener> <servlet><servlet-name>SpringMVC</servlet-name><servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class><init-param><description>spring MVC 配置文件</description><param-name>contextConfigLocation</param-name><param-value>classpath:/config/spring-mvc.xml</param-value><span style="font-size:24px;"><!– 子容器 –></span></init-param><load-on-startup>1</load-on-startup> </servlet>

上一篇关于xss攻击的预防措施

顶0踩0

主题推荐猜你在找

查看评论

* 以上用户言论只代表其个人观点,,不代表CSDN网站的观点或立场

核心技术类目

原以为“得不到”和“已失去”是最珍贵的,可原来把握眼前才是最重要的。

关于Spring mvc 不会滚的问题

相关文章:

你感兴趣的文章:

标签云: