1. Add the Simplecaptcha rack package simple enough verification code production library. 2. New Captchamodule Module Class
public class captchamodule { @At @Ok ("Raw:png") public bufferedimage next ( httpsession session, @Param ("W") int w, @Param ("H") int h) { if (w * h < 1) { //long or wide to 0? reset to default length width . w = 200; h = 60; } captcha captcha = new captcha.builder (w, h) .addtext ().Addbackground (New gradiatedbackgroundproducer ()) .gimp (New fisheyegimpyrenderer ()) .build (); string text = captcha.getanswer (); Session.setattribute (toolkit.captcha_attr, text); return captcha.getimage (); }}
Raw represents Rawview
PNG is the abbreviation for image/png in Rawview and is the description of data mime
The return value is BufferedImage, and this is image/png, so it turns into a picture display. Also support JPG/WEBP format, details refer to Rawview source bar.
CAPTCHA has more than n combination and configuration, the choice of their own
3. Add the Captcha text box to the page
<script type= "Text/javascript" > function next_captcha () { $ ("#captcha_img"). attr ("src", "${base}/captcha/next?_=" + new date (). GetTime ()); } </script> Verification Code <input name= "Captcha" type= "text" value= "" > </IMG>
650) this.width=650; "src=" Http://img.baidu.com/hi/jx2/j_0003.gif "alt=" J_0003.gif "/>650" this.width=650; "src=" Http://img.baidu.com/hi/jx2/j_0005.gif "alt=" J_0005.gif "/>
This article from the "12403903" blog, reproduced please contact the author!
To generate a "Login verification Code" method step