<img id="imgcode" src="${basePath}/captcha" οnclick="this.src = '${basePath}/captcha?v=' + Math.random()"/>
后台获取验证码图片
public void captcha(){ renderCaptcha(); }
验证验证码
if (!validateCaptcha("imgCode")) { renderJson(error("验证码错误")); return; }
//captchaName规定是_jfinal_captcha ICaptchaCache captchaCache = CaptchaManager.me().getCaptchaCache(); Captcha captcha = captchaCache.get(this.getCookie(captchaName)); System.out.println("Cookie中储存的数据: "+captchaName+"-->"+this.getCookie(captchaName)); System.out.println("captchaCache中储存的数据: "+captcha.getKey()+"-->"+captcha.getValue());
Cookie中储存的数据: _jfinal_captcha-->ae1908c8f58a4afbabfc44a205047f84
captchaCache中储存的数据: ae1908c8f58a4afbabfc44a205047f84-->9KPA