|
|
|
@ -21,13 +21,14 @@ public class CaptchaConfig
|
|
|
|
|
DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
|
|
|
|
|
Properties properties = new Properties();
|
|
|
|
|
// 是否有边框 默认为true 我们可以自己设置yes,no
|
|
|
|
|
properties.setProperty(KAPTCHA_BORDER, "yes");
|
|
|
|
|
properties.setProperty(KAPTCHA_BORDER, "no");
|
|
|
|
|
// 验证码文本字符颜色 默认为Color.BLACK
|
|
|
|
|
properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_COLOR, "black");
|
|
|
|
|
properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_COLOR, "blue");
|
|
|
|
|
// 验证码图片宽度 默认为200
|
|
|
|
|
properties.setProperty(KAPTCHA_IMAGE_WIDTH, "160");
|
|
|
|
|
// 验证码图片高度 默认为50
|
|
|
|
|
properties.setProperty(KAPTCHA_IMAGE_HEIGHT, "60");
|
|
|
|
|
properties.setProperty(KAPTCHA_TEXTPRODUCER_CHAR_SPACE, "10");
|
|
|
|
|
// 验证码文本字符大小 默认为40
|
|
|
|
|
properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_SIZE, "38");
|
|
|
|
|
// KAPTCHA_SESSION_KEY
|
|
|
|
@ -37,7 +38,11 @@ public class CaptchaConfig
|
|
|
|
|
// 验证码文本字体样式 默认为new Font("Arial", 1, fontSize), new Font("Courier", 1, fontSize)
|
|
|
|
|
properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_NAMES, "Arial,Courier");
|
|
|
|
|
// 图片样式 水纹com.google.code.kaptcha.impl.WaterRipple 鱼眼com.google.code.kaptcha.impl.FishEyeGimpy 阴影com.google.code.kaptcha.impl.ShadowGimpy
|
|
|
|
|
properties.setProperty(KAPTCHA_OBSCURIFICATOR_IMPL, "com.google.code.kaptcha.impl.ShadowGimpy");
|
|
|
|
|
//properties.setProperty(KAPTCHA_OBSCURIFICATOR_IMPL, "com.google.code.kaptcha.impl.ShadowGimpy");
|
|
|
|
|
properties.setProperty(KAPTCHA_NOISE_IMPL, "com.google.code.kaptcha.impl.NoNoise");
|
|
|
|
|
properties.setProperty(KAPTCHA_BACKGROUND_CLR_FROM, "white");
|
|
|
|
|
//
|
|
|
|
|
properties.setProperty(KAPTCHA_TEXTPRODUCER_CHAR_STRING,"0123456789");
|
|
|
|
|
Config config = new Config(properties);
|
|
|
|
|
defaultKaptcha.setConfig(config);
|
|
|
|
|
return defaultKaptcha;
|
|
|
|
|