Springboot 生成中文、算术等图形验证码

Springboot 生成中文、算术等图形验证码_第1张图片


   
      com.github.whvcse
      easy-captcha
      1.6.2
   


@Controller
public class CaptchaController {

    @RequestMapping("/captcha")
    public void captcha(HttpServletRequest request, HttpServletResponse response) throws Exception {
        CaptchaUtil.out(request, response);
        /**
         *Captcha captcha = new ChineseCaptcha();
         *获取本次生成的验证码
         *String text = captcha.text();
         *System.out.println(text);
         *
         *输出验证码图片到d盘
         *captcha.out(new FileOutputStream(new File("d:\\test.png")));
         *
         *算术验证码
         *Captcha captcha1 = new ArithmeticCaptcha();
         *获取本次生成的验证码
         *String text1 = captcha1.text();
         *System.out.println(text1);
         * CaptchaUtil.ver(verCode, request)   //返回 true 或false
         */
    }
}

你可能感兴趣的:(java,前端,servlet)