我的博客
欢迎来到我的博客
bunny.icu

ValidateCode生成验证码

ValidateCode生成验证码

可用于生成这样的验证码:

需要下载ValidateCode.jar

参考代码:

@RequestMapping("get_verification_code")
public void getVerificationCode(HttpSession session, HttpServletResponse response,
                            @RequestParam(defaultValue = "100") int width, @RequestParam(defaultValue = "30") int height,
                            @RequestParam(defaultValue = "4") int codeCount, @RequestParam(defaultValue = "6") int lineCount) throws IOException {
    ValidateCode validateCode = new ValidateCode(width, height, codeCount, lineCount);
    String code = validateCode.getCode().toLowerCase();
    System.out.println("验证码是:" + code);
    session.setAttribute(SessionKeyConst.VERIFICATION_CODE, code);
    validateCode.write(response.getOutputStream());
}

版权声明


本作品系原创, 转载须遵循 CC BY-NC-ND 4.0 许可协议
本文标题:ValidateCode生成验证码
本文链接:https://www.bunny.icu/archives/1180

推荐文章

发表评论

textsms
account_circle
email

bunny.icu

ValidateCode生成验证码
ValidateCode生成验证码
扫描二维码继续阅读
2019-07-20