首页 > 代码库 > spring

spring

spring

  • spring
    • spring相关
      • spring事物不回滚
      • spring mvc-redirect

spring相关

spring事物不回滚

@Transactional(rollbackFor = { Exception.class })
 public void test() {
 try {
 doDbStuff1();
 doDbStuff2();
 } catch (Exception e) {
 e.printStackTrace();
 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();//就是这一句了,加上之后,如果doDbStuff2()抛了异常,                                                                                       //doDbStuff1()是会回滚的
 }
 }

spring mvc-redirect

 @RequestMapping("/add")
 public String add(){
 return "channel/addindex";
 }
 @RequestMapping("/addSub")
 public String addSub(Channel channel){
 System.out.println(channel.toString());
 return "redirect:/channel/add";
 }

spring