SpringMVC框架中如何去掉登录验证码?

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SpringMVC框架中如何去掉登录验证码?相关的知识,希望对你有一定的参考价值。

图一是JSP部分代码,图二是验证部分代码下面是controller登录部分的代码@RequestMapping(value = "login", method = RequestMethod.POST) @ResponseBody public Map<String, Object> login(@RequestBody Map<String, Object> user) // 初始化 Response Response response = ResponseFactory.newInstance(); String result = Response.RESPONSE_RESULT_ERROR; String errorMsg = ""; // 获取当前的用户的 Subject Subject currentUser = SecurityUtils.getSubject(); // 判断用户是否已经登陆 if (currentUser != null && !currentUser.isAuthenticated()) String id = (String) user.get(USER_ID); String password = (String) user.get(USER_PASSWORD); Session session = currentUser.getSession(); UsernamePasswordToken token = new UsernamePasswordToken(id, password); try // 执行登陆操作 currentUser.login(token); /* 设置 session 中 userInfo 的其他信息 */ UserInfoDTO userInfo = (UserInfoDTO) session.getAttribute("userInfo"); // 设置登陆IP userInfo.setAccessIP(session.getHost()); // 记录登陆日志 systemLogService.insertAccessRecord(userInfo.getUserID(), userInfo.getUserName(), userInfo.getAccessIP(), SystemLogService.ACCESS_TYPE_LOGIN); // 设置登陆成功响应 result = Response.RESPONSE_RESULT_SUCCESS; catch (UnknownAccountException e) errorMsg = "unknownAccount"; catch (IncorrectCredentialsException e) errorMsg = "incorrectCredentials"; catch (AuthenticationException e) errorMsg = "authenticationError"; e.printStackTrace(); catch (SystemLogServiceException es ) errorMsg = "ServerError"; finally // 当登陆失败则清除session中的用户信息 if (result.equals(Response.RESPONSE_RESULT_ERROR)) session.setAttribute("userInfo", null); else errorMsg = "already login"; // 设置 Response response.setResponseResult(result); response.setResponseMsg(errorMsg); return response.generateResponse();

参考技术A 先把checkcode相关的代码全部去掉

以上是关于SpringMVC框架中如何去掉登录验证码?的主要内容,如果未能解决你的问题,请参考以下文章

如何去掉网站管理员登陆时的验证码?

游戏登陆时怎样去掉验证码啊

qq登陆验证码 ,怎么去掉啊

验证码怎么去掉?

DEDE去掉会员登录及注册验证码的方法

网站登陆验证码是在数据库里还是在文件中,在哪个文件,怎么去掉