今天在实现点击验证码图片切换图片功能(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());
}