1.使用servlet生成验证码时,<img src="imgcode.do">,访问/imgcode即可得到新的验证码,实现刷新验证码时务必要使请求url链接有变化才可生效,如:
src="imgcode.do?rand="+Math.random();//"imgcode.do"或"imgcode.do?"则无效
否则不会向服务器重新发出请求。
document.write(parseInt(10*Math.random())); //输出0~10之间的随机整数
document.write(Math.floor(Math.random()*10+1)); //输出1~10之间的随机整数
2.