diff --git a/src/main/java/com/yingjun/ssm/service/impl/UserServiceImpl.java b/src/main/java/com/yingjun/ssm/service/impl/UserServiceImpl.java index 00f50cd9f4ec6432a0ad7f2a845ee97c186e5783..32cc36f2a1fbf7ab5356fd3aa15c01c95658acac 100644 --- a/src/main/java/com/yingjun/ssm/service/impl/UserServiceImpl.java +++ b/src/main/java/com/yingjun/ssm/service/impl/UserServiceImpl.java @@ -8,6 +8,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Isolation; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; import javax.servlet.http.HttpSession; @@ -87,6 +90,7 @@ public class UserServiceImpl implements UserService { * 处理用户注册 * @param user */ + @Transactional(propagation= Propagation.REQUIRED,isolation = Isolation.READ_COMMITTED,rollbackFor=Throwable.class) @Override public void userRegister(User user, String code,HttpSession session) { try{ @@ -94,7 +98,7 @@ public class UserServiceImpl implements UserService { if(!emailCode.equals(code)){ throw new BizException("验证码错误"); } - if(1 == userDao.insertTUser(user)){ + if(1 != userDao.insertTUser(user)){ throw new Exception("插入数据影响函数不唯一"); } }catch (BizException biz){ diff --git a/src/main/java/com/yingjun/ssm/web/UserController.java b/src/main/java/com/yingjun/ssm/web/UserController.java index 20b849decb4d922e902887802d1aa3f452090546..afc8b430c678a2c1fb90ee651a9288dd1f24a71d 100644 --- a/src/main/java/com/yingjun/ssm/web/UserController.java +++ b/src/main/java/com/yingjun/ssm/web/UserController.java @@ -81,7 +81,7 @@ public class UserController { } catch (Exception e) { return new BaseResult<>(false, ResultEnum.INVALID_USER.getMsg()); } - return new BaseResult<>(true, "登陆成功"); + return new BaseResult<>(true, "注册成功"); } /** * 用户注册时获取邮箱验证码 diff --git a/src/main/webapp/resource/script/userResgiter.js b/src/main/webapp/resource/script/userResgiter.js index d4b4bc6b768a9d35de6bf2407a491770c144a87a..4065ad29605c409de6fa2365f23ff3a38611cc8c 100644 --- a/src/main/webapp/resource/script/userResgiter.js +++ b/src/main/webapp/resource/script/userResgiter.js @@ -93,11 +93,7 @@ function sure(){ dataType: "json", url: '/user/register', success: function (data) { - if (data.success) { - - } else { - - } + window.location.href="/user/login"; } });