@PostMapping("/sendMsg") public R msg(@RequestBody User user, HttpSession session) { String phone = user.getPhone();//获取手机号属性 if (StringUtils.isNotEmpty(phone)) { //获取长度为4的随机数字验证码 String code = ValidateCodeUtils.generateValidateCode(4).toString(); log.info("验证码: {}", code);//打印验证码在控制台 session.setAttribute(phone, code);//记住登录状态 } return R.error("手机号有误"); }
随机生成四位数验证码
最新推荐文章于 2022-11-30 09:59:54 发布