分类目录归档:SSH

Struts2+Spring中抛出一般异常(checked exception)事务不回滚的问题

在用String进程事务管理时,Spring只会在运行时异常(runtime exception)抛出时回滚数据库操作,如果我们自定义的异常或者其他没有继承runtime exception的异常抛出时,String不会回滚事务。如果你的抛出某种异常时,有两种方法。

继续阅读

Struts2中使用action标签包含jsp页面时出现乱码。

在jsp中使用了<s:action … />时,被包含的页面可能会出现乱码,经查询好像没有人把这个问题的方法写出来,这里记录一下。

只要在被包含的页面第一行加入 <%@page contentType=”text/html;charset=utf-8″%>(utf-8可替换为你用到的字符集)即可。

java.lang.ClassNotFoundException: org.springframework.dao.support.PersistenceExceptionTranslator

如果你的项目(我这里是用spring+hibernate时出现)里出现

找不到org.springframework.dao.support.PersistenceExceptionTranslator这个类,网上查了一下,都说要添加org.springframework.transaction-3.1.1.RELEASE.jar即可,实在找不到这个jar文件,官方的spring里也没有。

然后自己搜索了一下,找到这个 <-请点击,可看出PersistenceExceptionTranslator这个类已经在spring-tx里了,在你下载的spring框架的lib文件夹里找到spring-tx.jar引用即可。