|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package com.dsideal.sso.Controller;
|
|
|
|
|
|
|
|
|
|
import java.awt.image.BufferedImage;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
|
@ -142,7 +143,7 @@ public class WebLoginController extends Controller {
|
|
|
|
|
/**
|
|
|
|
|
* 获取验证码
|
|
|
|
|
*/
|
|
|
|
|
public void getCaptcha() {
|
|
|
|
|
public void getCaptcha() throws IOException {
|
|
|
|
|
HttpServletResponse response = getResponse();
|
|
|
|
|
// 设置相应类型,告诉浏览器输出的内容为图片
|
|
|
|
|
response.setContentType("image/jpeg");
|
|
|
|
@ -151,19 +152,14 @@ public class WebLoginController extends Controller {
|
|
|
|
|
response.setHeader("Cache-Control", "no-cache");
|
|
|
|
|
response.setDateHeader("Expire", 0);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
HttpSession session = getRequest().getSession();
|
|
|
|
|
CaptchaUtil tool = new CaptchaUtil();
|
|
|
|
|
StringBuffer code = new StringBuffer();
|
|
|
|
|
BufferedImage image = tool.genRandomCodeImage(code);
|
|
|
|
|
session.removeAttribute("captcha");
|
|
|
|
|
session.setAttribute("captcha", code.toString());
|
|
|
|
|
|
|
|
|
|
// 将内存中的图片通过流动形式输出到客户端
|
|
|
|
|
ImageIO.write(image, "JPEG", response.getOutputStream());
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
HttpSession session = getRequest().getSession();
|
|
|
|
|
CaptchaUtil tool = new CaptchaUtil();
|
|
|
|
|
StringBuffer code = new StringBuffer();
|
|
|
|
|
BufferedImage image = tool.genRandomCodeImage(code);
|
|
|
|
|
session.removeAttribute("captcha");
|
|
|
|
|
session.setAttribute("captcha", code.toString());
|
|
|
|
|
// 将内存中的图片通过流动形式输出到客户端
|
|
|
|
|
ImageIO.write(image, "JPEG", response.getOutputStream());
|
|
|
|
|
renderNull();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|