package com.nq.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 GoogleCodeConfig { // // // // // // // no // // 100 // // 45 // // // // // // 0123456789abcdefg // // red // // // // 33 // // 4 // // 5 // // // 宋體,楷體,微軟雅黑 // // // com.google.code.kaptcha.impl.NoNoise // // // // // @Bean public DefaultKaptcha captchaProducer() { DefaultKaptcha defaultKaptcha = new DefaultKaptcha(); Properties properties = new Properties(); properties.setProperty("kaptcha.border", "no"); properties.setProperty("kaptcha.image.width", "100"); properties.setProperty("kaptcha.image.height", "45"); properties.setProperty("kaptcha.textproducer.char.string", "0123456789abcdefg"); properties.setProperty("kaptcha.textproducer.font.color", "red"); properties.setProperty("kaptcha.textproducer.font.size", "33"); properties.setProperty("kaptcha.textproducer.char.length", "4"); properties.setProperty("kaptcha.textproducer.char.space", "5"); properties.setProperty("kaptcha.textproducer.font.names", "宋體,楷體,微軟雅黑"); properties.setProperty("kaptcha.noise.impl", "com.google.code.kaptcha.impl.NoNoise"); Config config = new Config(properties); defaultKaptcha.setConfig(config); return defaultKaptcha; } }