Browse Source

返回图片类型调整

chengyao 3 years ago
parent
commit
bc12dd72a4

+ 1 - 1
src/main/java/com/diagbot/entity/ImageCaptchaParams.java

@@ -14,7 +14,7 @@ public class ImageCaptchaParams {
      * 默认图片验证码的文字内容
      */
     public static final String DEFAULT_WORDS = "123456789abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ";
-    public static final String DEFAULT_FORMAT = "png";
+    public static final String DEFAULT_FORMAT = "jpeg";
     /**
      * 图片验证码宽度
      */

+ 4 - 2
src/main/java/com/diagbot/facade/SysUserFacade.java

@@ -124,10 +124,12 @@ public class SysUserFacade extends SysUserServiceImpl {
     }
 
     public void getCaptcha(HttpServletRequest request, HttpServletResponse response) throws IOException {
-        response.setContentType("image/png");
+        response.setContentType("image/jpeg");
+        response.setHeader("Pragma", "no-cache");
+        response.setHeader("Cache-Control", "no-cache");
+        response.setDateHeader("Expires", 0);
         HttpSession session = request.getSession();
         String captchaId = session.getId();
-        session.setAttribute("captchaId", captchaId);
         ServletOutputStream outputStream = response.getOutputStream();
         ImageCaptchaUtil imageCaptchaUtil = new ImageCaptchaUtil();
         BufferedImage image = imageCaptchaUtil.createRandom();