无关风月
2025-05-08 9486766c806fe1d9e082b2fd02ea1cc558f1b443
cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/system/KaptchaController.java
@@ -1,5 +1,6 @@
package com.dsh.guns.modular.system.controller.system;
import com.dsh.course.util.RedisUtil;
import com.dsh.guns.config.properties.GunsProperties;
import com.dsh.guns.core.util.FileUtil;
import com.google.code.kaptcha.Constants;
@@ -23,6 +24,7 @@
 * @author fengshuonan
 * @date 2017-05-05 23:10
 */
@Controller
@RequestMapping("/kaptcha")
public class KaptchaController {
@@ -32,6 +34,9 @@
    @Autowired
    private Producer producer;
    @Autowired
    private RedisUtil redisUtil;
    /**
     * 生成验证码
@@ -56,10 +61,11 @@
        // create the text for the image
        String capText = producer.createText();
        String cookie = request.getHeader("cookie");
        System.err.println("cookie:" + cookie);
        redisUtil.setStrValue(cookie, capText, 300);
        // store the text in the session
        session.setAttribute(Constants.KAPTCHA_SESSION_KEY, capText);
        // create the image with the text
        BufferedImage bi = producer.createImage(capText);
        ServletOutputStream out = null;