开发web应用时firefox获取小的静态图片时重复提交请求的bug

在开发web应用过程中,遇到Firefox浏览器在获取小尺寸静态验证码图片时会重复提交请求的问题。通过调整图片大小,发现当图片尺寸增大时,问题消失。这表明问题可能与Firefox对小图片的处理方式有关。文章探讨了这个问题的本质原因,并提供了可能的解决方案。
摘要由CSDN通过智能技术生成
最近项目需要图形验证码,于是乎着手写了一个,代码如下:
/**
省略import
*/
@Controller
public class CaptchaController {
	private static final Logger logger = Logger
			.getLogger(CaptchaController.class);
	private static final String appCaptchaCookieKey = "APPCAPTCHACOOKIE";
	@Autowired
	private Producer captchaProducer;
	
	@Autowired
	private RedisComponent redisComponent;
	@Value("${CAPTCHA_EXPIRE_TIME}")
	private int captchaExpireTime;
	/**
	 * @param request
	 * @param response
	 * @throws IOException 
	 */
	@RequestMapping(value = "/captcha.jpg", method = RequestMethod.GET)
	public void getCaptcha(HttpServletRequest request,
			HttpServletResponse response) throws IOException {
		response.setDateHeader("Expires", 0);
		response.setHeader("Cache-Control",
				"no-store, no-cache, must-revalidate");
		response.addHeader("Cache-Control", "post-check=0, pre-check=0");
		response.setHeader("Pragma", "no-cache");
		response.setContentType("image/jpeg");
		ServletOutputStream out = null;
		try {
			String uniqCode = UUID.randomUUID().toString().replaceAll("-", "");
			logger.info("生成的图形验证码唯一键:"+uniqCode);
			String capText = captchaProducer.createText();
			// 存储验证码文字到redis
			logger.info("生成的验证码文字:"+capText);
			redisCompone
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值