切换验证码的坑

今天在实现点击验证码图片切换图片功能(src请求到后台生成图片写到img标签),发现填写数据总是和session里不一致,而且session存的属性值一直不能改变

 function change(){
       var img=document.getElementById("captchaImage");
       img.setAttribute("src","http://localhost:8080/shop/verifyCode?"+new Date().getTime());
    }

原因:"http://localhost:8080/shop/verifyCode"会重新发起一次会话,造成session不一致,改为:

 function change(){
       var img=document.getElementById("captchaImage");
       img.setAttribute("src","${pageContext.request.contextPath}/verifyCode?"+new Date().getTime());
    }

猜你喜欢

转载自blog.csdn.net/qq_37514822/article/details/83016452