这种方式后台会报错,好像是
getOutputStream() has already been called for this response
后来改成了servlet的方式。添加了这样几行代码:
mSession.setAttribute("verificationCode",sRand);//将验证码存入session
g.dispose();
os = mResponse.getOutputStream();
ImageIO.write(image, "JPEG",os);
os.flush();
os