EasyCaptcha生成验证码

2021-05-14  本文已影响0人  天马行空_9f6e

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 "验证码校验不通过";

}

}

上一篇下一篇

猜你喜欢

热点阅读