@ApiOperation("CaptchaUtil使用:图形验证码")
@GetMapping("/captchaUtil")
public void captchaUtil(HttpServletRequest request, HttpServletResponse response) {
//生成验证码图片
CircleCaptcha lineCaptcha = CaptchaUtil.createCircleCaptcha(200, 100);
try {
request.getSession().setAttribute("CAPTCHA_KEY", lineCaptcha.getCode());
response.setContentType("image/png");//告诉浏览器输出内容为图片
response.setHeader("Pragma", "No-cache");//禁止浏览器缓存
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expire", 0);
lineCaptcha.write(response.getOutputStream());
} catch (IOException e) {
e.printStackTrace();
}
}