jfinal-captcha 使用简单好看的验证码

https://github.com/Dreampie/jfinal-captcha jfinal-captcha是一款验证吗插件:

1 <dependency>
2       <groupId>cn.dreampie</groupId>
3       <artifactId>jfinal-captcha</artifactId>
4       <version>${jfinal-captcha.version}</version>
5  </dependency>

目前刚刚发布第一个版本0.1:

1 <jfinal-captcha.version>0.1</jfinal-captcha.version>

使用方法:

 1  /**
 2    * 验证码
 3    */
 4   public void captcha() {
 5     int width = 0, height = 0, minnum = 0, maxnum = 0, fontsize = 0, fontmin = 0, fontmax = 0;
 6     CaptchaRender captcha = new CaptchaRender();
 7     if (isParaExists("width")) {
 8       width = getParaToInt("width");
 9     }
10     if (isParaExists("height")) {
11       height = getParaToInt("height");
12     }
13     if (width > 0 && height > 0)
14       captcha.setImgSize(width, height);
15     if (isParaExists("minnum")) {
16       minnum = getParaToInt("minnum");
17     }
18     if (isParaExists("maxnum")) {
19       maxnum = getParaToInt("maxnum");
20     }
21     if (minnum > 0 && maxnum > 0)
22       captcha.setFontNum(minnum, maxnum);
23     if (isParaExists("fontsize")) {
24       fontsize = getParaToInt("fontsize");
25     }
26     if (fontsize > 0)
27       captcha.setFontSize(fontsize, fontsize);
28     //干扰线数量 默认0
29     captcha.setLineNum(0);
30     //噪点数量 默认50
31     captcha.setArtifactNum(0);
32     //使用字符  去掉0和o  避免难以确认
33 //    captcha.setCode("ABCDEFGHIJKLMNPQRSTUVWXYZ123456789");
34     //验证码在session里的名字 默认 captcha,创建时间为:名字_time
35 //    captcha.setCaptchaName("captcha");
36     //验证码颜色 默认黑色
37 //    captcha.setDrawColor(new Color(255,0,0));
38     //背景干扰物颜色  默认灰
39 //    captcha.setDrawBgColor(new Color(0,0,0));
40     //背景色+透明度 前三位数字是rgb色,第四个数字是透明度  默认透明
41 //    captcha.setBgColor(new Color(225, 225, 0, 100));
42     //滤镜特效 默认随机特效 //曲面Curves //大理石纹Marble //弯折Double //颤动Wobble //扩散Diffuse
43 //    captcha.setFilter(CaptchaRender.FilterFactory.Curves);
44     //随机色  默认黑验证码 灰背景元素
45     captcha.setRandomColor(true);
46     render(captcha);
47   }
48 
49 //  html
50 /captcha?width=128&height=45&fontsize=30&time={{time}}

验证码默认使用captcha作为名称存在session中,可以通过setCaptchaName(String name)改变名字

 

转载于:https://www.cnblogs.com/gzcblogs/p/7809159.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值