带验证码的登录效果图
登录成功时,记录用户名和访问次数
登录失败,弹出错误提示
方法一:应用request对象获取表单数据实现登录操作
代码结构:
index.jsp源码及详解:
当表单被提交时,数据会被提交到check.jsp中去,此处表单的提交实在js的mycheck()方法中完成的。
Stringintsum=intmethod+""+intmethod2+intmethod3+intmethod4;此处+""是为了将int数据类型转为String类型。
登录页面functionmycheck(){//定义mycheck()方法
if(form1.UserName.value==""){
alert("用户名不能为空!");
form1.UserName.focus();return;
}if(form1.PWD.value==""){
alert("密码不能为空!");
form1.PWD.focus();return;
}if(fo