真香!推薦一個(gè)超級簡單 Java 圖形驗(yàn)證碼模塊
來源于網(wǎng)絡(luò)
簡介
Java 圖形驗(yàn)證碼,支持 Gif、中文、算術(shù)等類型,可用于 Java Web、JavaSE 等項(xiàng)目。
效果展示

集成項(xiàng)目
maven 方式引入:
<dependencies>
<dependency>
<groupId>com.github.whvcse</groupId>
<artifactId>easy-captcha</artifactId>
<version>1.6.2</version>
</dependency>
</dependencies>
在 SpringBoot 中使用
@Controller
public class CaptchaController {
@RequestMapping("/captcha")
public void captcha(HttpServletRequest request, HttpServletResponse response) throws Exception {
CaptchaUtil.out(request, response);
}
}
前端 html 代碼:
<img src="/captcha" width="130px" height="48px" />
判斷驗(yàn)證碼是否正確:
@Controller
public class LoginController {
@PostMapping("/login")
public JsonResult login(String username,String password,String verCode){
if (!CaptchaUtil.ver(verCode, request)) {
CaptchaUtil.clear(request); // 清除session中的驗(yàn)證碼
return JsonResult.error("驗(yàn)證碼不正確");
}
}
}
源碼:https://gitee.com/whvse/EasyCaptcha
演示

地址:https://tools.cloudbed.vip
小結(jié)
超級簡單,種類豐富,支持多種接入方式,推薦給各位小伙伴!
推薦閱讀:
怎么接私貨?這個(gè)渠道你100%有用!請收藏!
評論
圖片
表情
