|
|
@@ -74,12 +74,24 @@ public class CaptchaController
|
|
|
capStr = code = captchaProducer.createText();
|
|
|
image = captchaProducer.createImage(capStr);
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // 如果配置的验证码类型不是"math"或"char",则默认使用"char"类型
|
|
|
+ capStr = code = captchaProducer.createText();
|
|
|
+ image = captchaProducer.createImage(capStr);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加空值检查
|
|
|
+ if (image == null) {
|
|
|
+ return AjaxResult.error("验证码生成失败");
|
|
|
+ }
|
|
|
|
|
|
redisCache.setCacheObject(verifyKey, code, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES);
|
|
|
// 转换流信息写出
|
|
|
FastByteArrayOutputStream os = new FastByteArrayOutputStream();
|
|
|
try
|
|
|
{
|
|
|
+ assert image != null;
|
|
|
ImageIO.write(image, "jpg", os);
|
|
|
}
|
|
|
catch (IOException e)
|