空指针错误,获取登录信息userModel值为null
下单失败,debug过程中发现
UserModel userModel=(UserModel)httpServletRequest.getSession().getAttribute("LOGIN_USER");这一句得到的userModel值为null
下单失败,debug过程中发现
UserModel userModel=(UserModel)httpServletRequest.getSession().getAttribute("LOGIN_USER");这一句得到的userModel值为null
2019-01-28
在登录请求中把用户的信息存储到session中
@PostMapping("/login")
public CommonReturnType login(@RequestParam(value = "telephone") String telephone,
@RequestParam(value = "password") String password) throws BusinessException, UnsupportedEncodingException, NoSuchAlgorithmException {
//入参校验
if (StringUtils.isEmpty(telephone) || StringUtils.isEmpty(password)) {
throw new BusinessException(EnumBussinessError.PARAMETER_VALIDATION_ERROR);
}
//用户登录校验,校验登录是否合法
UserModel userModel = userService.validateLogin(telephone, this.encodeByMD5(password));
//将登录凭证加入到用户登录成功的session内
request.getSession().setAttribute("IS_LOGIN", true);
request.getSession().setAttribute("LOGIN_USER", userModel);
return CommonReturnType.create(null);
}举报