Skip to content

验证码

提供获取图片验证码,并提供验证入口。你可以通过/create-captcha或者/refresh-captcha来创建或者刷新验证码,其实他们两个没有区别执行的都是一样的函数

提示

如果需要,可以设置/create-captcha,/refresh-captcha这两个url不需要授权访问

依赖

xml
<dependency>
    <groupId>org.seedltd</groupId>
    <artifactId>seedltd-captcha-starter</artifactId>
</dependency>

属性

字段说明默认值可选值
seedltd.captcha.enabled是否启用验证码true
seedltd.captcha.width验证码宽度120
seedltd.captcha.height验证码高度40
seedltd.captcha.length验证码字数,mode=ARITHMETIC该属性无效4
seedltd.captcha.mode验证码模式GIFcn.seedltd.captcha.properties.CaptchaMode
seedltd.captcha.type验证码内容类型2cn.seedltd.captcha.properties.CharType
seedltd.captcha.store验证码存储类型memoryredis, memory
seedltd.captcha.expired验证码过期时间,单位秒120
seedltd.captcha.initialCapacityStoreMode.memory 的时候初始化容器大小528
seedltd.captcha.maximumSizeStoreMode.memory 的时候容器最大存储容量10240
seedltd.captcha.keyParameter获取验证码时候的唯一key值captchaKay

验证

java
@Autowired
private CaptchaStoreService captchaStoreService;

// 验证用户输入的验证码是否正确
captchaStoreService.verifyCaptcha(key, captcha)

// 删除验证码
captchaStoreService.deleteCaptcha(key)

API

获取验证码

  • Method:GET

  • URL:/create-captcha,/refresh-captcha

  • Parameter

    类型字段说明默认值可选值是否必填
    String[seedltd.captcha.keyParameter]获取验证码的唯一标识,可以通过配置文件设置--
    IntegercharType验证码内容类型全局配置参考:cn.seedltd.captcha.properties.CharType
    Integerwidth验证码宽度全局配置-
    Integerheight验证码高度全局配置-
    Integerlength验证码字数,mode=ARITHMETIC该属性无效全局配置-
    Stringmode验证码模式全局配置参考:cn.seedltd.captcha.properties.CaptchaMode

粤ICP备2022017444号