鉴权
This commit is contained in:
27
src/main/java/cn/van/business/config/KaptchaConfig.java
Normal file
27
src/main/java/cn/van/business/config/KaptchaConfig.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package cn.van.business.config;
|
||||
|
||||
import com.google.code.kaptcha.impl.DefaultKaptcha;
|
||||
import com.google.code.kaptcha.util.Config;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
@Configuration
|
||||
public class KaptchaConfig {
|
||||
|
||||
@Bean
|
||||
public DefaultKaptcha kaptchaProducer() {
|
||||
DefaultKaptcha kaptcha = new DefaultKaptcha();
|
||||
Properties properties = new Properties();
|
||||
|
||||
// 设置验证码参数
|
||||
properties.setProperty("kaptcha.image.width", "150");
|
||||
properties.setProperty("kaptcha.image.height", "50");
|
||||
properties.setProperty("kaptcha.textproducer.char.string", "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
||||
properties.setProperty("kaptcha.textproducer.char.length", "4");
|
||||
|
||||
kaptcha.setConfig(new Config(properties));
|
||||
return kaptcha;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user