0
点赞
收藏
分享

微信扫一扫

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


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

<dependencies>
   <dependency>
      <groupId>com.github.whvcse</groupId>
      <artifactId>easy-captcha</artifactId>
      <version>1.6.2</version>
   </dependency>
</dependencies>

@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
         */
    }
}

举报

相关推荐

0 条评论