「今日推荐」
简介
效果展示
集成项目
Gradle方式引入:
dependencies {compile 'com.github.whvcse:easy-captcha:1.6.2'}
Maven方式引入:
<dependencies><dependency><groupId>com.github.whvcse</groupId><artifactId>easy-captcha</artifactId><version>1.6.2</version></dependency></dependencies>
@Controllerpublic class CaptchaController {@RequestMapping("/captcha")public void captcha(HttpServletRequest request, HttpServletResponse response) throws Exception {CaptchaUtil.out(request, response);}}
<img src="/captcha" width="130px" height="48px" />
@Controllerpublic class LoginController {@PostMapping("/login")public JsonResult login(String username,String password,String verCode){if (!CaptchaUtil.ver(verCode, request)) {CaptchaUtil.clear(request); // 清除session中的验证码return JsonResult.error("验证码不正确");}}}
@Controllerpublic class CaptchaController {@RequestMapping("/captcha")public void captcha(HttpServletRequest request, HttpServletResponse response) throws Exception {// 设置位数CaptchaUtil.out(5, request, response);// 设置宽、高、位数CaptchaUtil.out(130, 48, 5, request, response);// 使用gif验证码GifCaptcha gifCaptcha = new GifCaptcha(130,48,4);CaptchaUtil.out(gifCaptcha, request, response);}}
下面推荐一个漂亮的项目,使用了该验证码功能。该项目也是开源的,喜欢的小伙伴们可以文章最后获取下载。
项目演示
|
|
|
|
|
|
|
|
最后
最热门的文章
2021-04-01
2021-03-30
2021-03-28
2021-03-27










