为了账号安全,请及时绑定邮箱和手机立即绑定

ssm整合shiro时出现错误,求解!在线等!

ssm整合shiro时出现错误,求解!在线等!

qq_那一眸的风情_03788798 2016-11-03 16:10:56
报错:还没登录,SecurityUtils.getSubject().isAuthenticated()为什么是ture,他得知应该是false才对呀 @RequestMapping(value = "login.do", method = RequestMethod.POST) @ResponseBody public ModelMap login() throws Exception { logger.info("进入了userController"); String username = request.getParameter("username"); String password = request.getParameter("password"); String verifycode = request.getParameter("code"); String sessioncode = (String) SecurityUtils.getSubject().getSession().getAttribute("code"); logger.info("接收的信息:" + username + password + verifycode + sessioncode); ModelMap parmars = new ModelMap(); UsernamePasswordToken token = new UsernamePasswordToken(username, password); logger.info(token.toString()+"接收令牌"); Subject subject = SecurityUtils.getSubject(); logger.info(subject.getPrincipal()+"获取登陆者"); try{ if (verifycode.equalsIgnoreCase(sessioncode)) { System.out.println(subject.isAuthenticated()+"-------------"); //判断身份是否进行登录验证 if (!subject.isAuthenticated()) { token.setRememberMe(true); subject.login(token); logger.info(token.getUsername() + "登录成功"); parmars.put("code", Code.SUCCESS); } else { parmars.put("code", Code.ISREMEMBERED); } } else { parmars.put("code", Code.CODE_WRONG); } } catch (Exception e) { e.printStackTrace(); parmars.put("code", Code.UNKOWN_WRONG); logger.info("shiro导致的系统错误"); } return parmars; }
查看完整描述

1 回答

?
慕粉4075985

TA贡献104条经验 获得超33个赞

之前登录过,被remember

查看完整回答
反对 回复 2017-01-04
  • 1 回答
  • 0 关注
  • 2453 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信