Loading

kapacha生成验证码配置

`
@Component

public class KaptcharConfig {

@Bean
public DefaultKaptcha getDefaultKaptcha() {
    com.google.code.kaptcha.impl.DefaultKaptcha defaultKaptcha = new com.google.code.kaptcha.impl.DefaultKaptcha();
    Properties properties = new Properties();
    // 图片边框
    properties.setProperty("kaptcha.border", "yes");
    // 边框颜色
    properties.setProperty("kaptcha.border.color", "105,179,90");
    // 字体颜色
    properties.setProperty("kaptcha.textproducer.font.color", "blue");
    // 图片宽
    properties.setProperty("kaptcha.image.width", "130");
    // 图片高
    properties.setProperty("kaptcha.image.height", "50");
    // 字体大小
    properties.setProperty("kaptcha.textproducer.font.size", "40");
    // session key
   //   properties.setProperty("kaptcha.session.key", "code");
    // 验证码长度
    properties.setProperty("kaptcha.textproducer.char.length", "4");
    // 字体
    properties.setProperty("kaptcha.textproducer.font.names", "宋体,楷体,微软雅黑");
    Config config = new Config(properties);
    defaultKaptcha.setConfig(config);
    return defaultKaptcha;
}

}`

posted @ 2023-07-05 10:20  潇潇蔡鸡  阅读(18)  评论(0)    收藏  举报