美文网首页
EasyCaptcha生成验证码

EasyCaptcha生成验证码

作者: 天马行空_9f6e | 来源:发表于2021-05-14 00:05 被阅读0次

    Maven配置

    <!-- https://mvnrepository.com/artifact/com.github.whvcse/easy-captcha -->

            <dependency>

                <groupId>com.github.whvcse</groupId>

                <artifactId>easy-captcha</artifactId>

                <version>1.6.2</version>

            </dependency>

    在编写EasyCaptchaController直接调用

    package com.bruce.portal.web.controller;

    import com.wf.captcha.utils.CaptchaUtil;

    import org.springframework.web.bind.annotation.GetMapping;

    import org.springframework.web.bind.annotation.RequestMapping;

    import org.springframework.web.bind.annotation.RestController;

    import javax.servlet.http.HttpServletRequest;

    import javax.servlet.http.HttpServletResponse;

    import java.io.IOException;

     

    @RestController

    @RequestMapping("/easy-Captcha")

    public class EasyCaptchaController {

    @RequestMapping("/generatorCode")

    public void generatorCode(HttpServletRequest request,HttpServletResponse response) {

    try {

    CaptchaUtil.out(request,response);

    }catch (IOException e) {

    e.printStackTrace();

    }

    }

    @GetMapping("/verify")

    public String verify(String verifyCode,HttpServletRequest request) {

    boolean flag =CaptchaUtil.ver(verifyCode, request);

    if (flag) {

    return "验证码校验验通过";

    }

    return "验证码校验不通过";

    }

    }

    相关文章

      网友评论

          本文标题:EasyCaptcha生成验证码

          本文链接:https://www.haomeiwen.com/subject/jwsfjltx.html