hibernate+spring(aop事物控制)+struts插入数据在action中如何捕获异常

来源:百度知道 编辑:UC知道 时间:2024/06/02 01:38:34
我要插入的数据可能会违反重复约束

1,使用编程时事务,那么直接try catch就可以
2.使用声明式事务,只需要在struts的配置文件里面配置就ok了

try catch 或者 throws 就可以啦!

你在写dao层的方法时,每个方法都throws异常,这样你的service层在调用dao层时就要try catch捕获异常了,同理在service层里方法也throws异常。

try catch 撒,这都跑来问-。-