1.验证码图片标签:
<img alt="验证码" name="validateCodeImg" id="validateCodeImg" src="${rootPath}/validateCode" οnclick="refreshCode()" width="56" height="20" />
2.验证码刷新js
<script type="text/javascript">
function refre shCode() {document.getElementById("validateCodeImg").src="${rootPath}/validateCode?Math.random()";
}//在请求后面添加 Math.random(),让图片刷新成功
</script>
3.在首次加载验证码的页面,为body添加onload事件,更新验证码,要不然会导致第一次的检验验证码时,从session中获取的验证码为null,导致验证码验证失败
<body οnlοad="refreshCode()">