@RestController
@RequestMapping("/sms/system")
public class SystemController {@GetMapping("/getVerifiCodeImage")public void getVerifiCodeImage(HttpServletRequest request, HttpServletResponse response){//获取图片BufferedImage verifiCodeImage = CreateVerifiCodeImage.getVerifiCodeImage();//获取图片上的验证码String verifiCode = new String(CreateVerifiCodeImage.getVerifiCode());//将验证码文本放入session域,为下一次验证做准备HttpSession session = request.getSession();session.setAttribute("verifiCode",verifiCode);//将验证码图片响应给浏览器try {ImageIO.write(verifiCodeImage,"JPEG",response.getOutputStream());} catch (IOException e) {e.printStackTrace();}}
}