📄 defaultscontroller.groovy
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -