defaultscontroller.groovy
来自「一个为 Java/J2EE生成的最简化CAPTCHA的框架」· GROOVY 代码 · 共 73 行
GROOVY
73 行
import java.awt.image.BufferedImageimport nl.captcha.Captchaimport nl.captcha.backgrounds.*import nl.captcha.servlet.CaptchaServletUtil/*** This controller shows how CAPTCHAs are built using SimpleCaptcha. Each action* builds a CAPTCHA with the default providers, e.g. addText() with no argument. ** Example call:** http://localhost:8080/sc/defaults/simple***/class DefaultsController { def final WIDTH = 200 def final HEIGHT = 50 def simple = { def captcha = new Captcha.Builder(WIDTH, HEIGHT) .addText() .build() CaptchaServletUtil.writeImage(response, captcha.image) } def border = { def captcha = new Captcha.Builder(WIDTH, HEIGHT) .addText() .addBorder() .build() CaptchaServletUtil.writeImage(response, captcha.image) } def gimp = { def captcha = new Captcha.Builder(WIDTH, HEIGHT) .addText() .gimp() .build() CaptchaServletUtil.writeImage(response, captcha.image) } def noisy = { def captcha = new Captcha.Builder(WIDTH, HEIGHT) .addText() .addNoise() .build() CaptchaServletUtil.writeImage(response, captcha.image) } def noisygimp = { def captcha = new Captcha.Builder(WIDTH, HEIGHT) .addText() .gimp() .addNoise() .addBorder() .build() CaptchaServletUtil.writeImage(response, captcha.image) } def all = { def captcha = new Captcha.Builder(WIDTH, HEIGHT) .addText() .gimp() .addNoise() .addBackground() .addBorder() .build() CaptchaServletUtil.writeImage(response, captcha.image) }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?