jfinal重写图形验证码,生成纯数字验证码(jfinal-3.3)。
public class CaptchaSmallRender extends CaptchaRender {
// 验证码随机字符数组
protected static final char[] charArray = "0123456789".toCharArray();
@Override
protected String getRandomString() {
char[] randomChars = new char[4];
for (int i = 0; i < randomChars.length; i++) {
randomChars[i] = charArray[random.nextInt(charArray.length)];
}
return String.valueOf(randomChars);
}
}
//@ValidateTOKEN(isValidate = false)
public void captcha() {
render(new CaptchaSmallRender());
}
还没有评论,来说两句吧...