Merge b3c3b328fa
into f6cb6062f5
This commit is contained in:
commit
5d1ad85ed0
@ -50,6 +50,11 @@ public class ArithmeticCaptcha extends ArithmeticCaptchaAbstract {
|
|||||||
return toBase64("data:image/png;base64,");
|
return toBase64("data:image/png;base64,");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getContentType() {
|
||||||
|
return "image/png";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成验证码图形
|
* 生成验证码图形
|
||||||
*
|
*
|
||||||
|
@ -46,6 +46,11 @@ public class ChineseCaptcha extends ChineseCaptchaAbstract {
|
|||||||
return toBase64("data:image/png;base64,");
|
return toBase64("data:image/png;base64,");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getContentType() {
|
||||||
|
return "image/png";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成验证码图形
|
* 生成验证码图形
|
||||||
*
|
*
|
||||||
|
@ -79,6 +79,11 @@ public class ChineseGifCaptcha extends ChineseCaptchaAbstract {
|
|||||||
return toBase64("data:image/gif;base64,");
|
return toBase64("data:image/gif;base64,");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getContentType() {
|
||||||
|
return "image/gif";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 画随机码图
|
* 画随机码图
|
||||||
*
|
*
|
||||||
|
@ -85,6 +85,11 @@ public class GifCaptcha extends Captcha {
|
|||||||
return toBase64("data:image/gif;base64,");
|
return toBase64("data:image/gif;base64,");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getContentType() {
|
||||||
|
return "image/gif";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 画随机码图
|
* 画随机码图
|
||||||
*
|
*
|
||||||
|
@ -50,6 +50,11 @@ public class SpecCaptcha extends Captcha {
|
|||||||
return toBase64("data:image/png;base64,");
|
return toBase64("data:image/png;base64,");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getContentType() {
|
||||||
|
return "image/png";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成验证码图形
|
* 生成验证码图形
|
||||||
*
|
*
|
||||||
|
@ -116,6 +116,13 @@ public abstract class Captcha extends Randoms {
|
|||||||
*/
|
*/
|
||||||
public abstract String toBase64();
|
public abstract String toBase64();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取图片类型
|
||||||
|
*
|
||||||
|
* @return 图片格式,MIME类型
|
||||||
|
*/
|
||||||
|
public abstract String getContentType();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 输出base64编码
|
* 输出base64编码
|
||||||
*
|
*
|
||||||
|
@ -117,6 +117,7 @@ public class CaptchaUtil {
|
|||||||
*/
|
*/
|
||||||
public static void out(Captcha captcha, HttpServletRequest request, HttpServletResponse response)
|
public static void out(Captcha captcha, HttpServletRequest request, HttpServletResponse response)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
response.setContentType(captcha.getContentType());
|
||||||
setHeader(response);
|
setHeader(response);
|
||||||
request.getSession().setAttribute(SESSION_KEY, captcha.text().toLowerCase());
|
request.getSession().setAttribute(SESSION_KEY, captcha.text().toLowerCase());
|
||||||
captcha.out(response.getOutputStream());
|
captcha.out(response.getOutputStream());
|
||||||
@ -152,7 +153,6 @@ public class CaptchaUtil {
|
|||||||
* @param response HttpServletResponse
|
* @param response HttpServletResponse
|
||||||
*/
|
*/
|
||||||
public static void setHeader(HttpServletResponse response) {
|
public static void setHeader(HttpServletResponse response) {
|
||||||
response.setContentType("image/gif");
|
|
||||||
response.setHeader("Pragma", "No-cache");
|
response.setHeader("Pragma", "No-cache");
|
||||||
response.setHeader("Cache-Control", "no-cache");
|
response.setHeader("Cache-Control", "no-cache");
|
||||||
response.setDateHeader("Expires", 0);
|
response.setDateHeader("Expires", 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user