已有pwdCount的实体类对应数据库pwdCount在use表里代表(登录错误次数)的字段
还有config.xml文件中作为登录错误的限制次数 pwdcount
现在实现登录错误次数超过限制次数就禁用 这里产生问题了
具体代码:
int pwdCount=Integer. parseInt(com.cms.Configuration. config().findConfigs( "systemConf" ).find("pwdCount" ));//将config文件里的限制数赋给pwdCount
if (!pwd_trans.equals(loginForm.getPassword())) { //假如密码比较为假
if (user.getPwdCount()>pwdCount) { //如果用户登录错误的次数大于限制数
user.setUserState(1); //禁用
DAOFactory. getInstance().getUserDAO().modify(user);//修改属性
errors.add( "error_checkCode", //
new ActionError("error.loginForm.checkCode.error" ));//
saveErrors(httpServletRequest, errors);//
return actionMapping.getInputForward(); //
}现在错误现象 禁用次数一直不对 而且后台错误次数奇怪的分为俩组:登录错误1次 登录错误2次 登录错误2次 登录错误3次 登录错误3次 登录错误4次 登录错误4次
还有一个问题 if (user.getPwdCount()>pwdCount)中pwdCount为3时 还出现登录错误次数为4.
还有config.xml文件中作为登录错误的限制次数 pwdcount
现在实现登录错误次数超过限制次数就禁用 这里产生问题了
具体代码:
int pwdCount=Integer. parseInt(com.cms.Configuration. config().findConfigs( "systemConf" ).find("pwdCount" ));//将config文件里的限制数赋给pwdCount
if (!pwd_trans.equals(loginForm.getPassword())) { //假如密码比较为假
if (user.getPwdCount()>pwdCount) { //如果用户登录错误的次数大于限制数
user.setUserState(1); //禁用
DAOFactory. getInstance().getUserDAO().modify(user);//修改属性
errors.add( "error_checkCode", //
new ActionError("error.loginForm.checkCode.error" ));//
saveErrors(httpServletRequest, errors);//
return actionMapping.getInputForward(); //
}现在错误现象 禁用次数一直不对 而且后台错误次数奇怪的分为俩组:登录错误1次 登录错误2次 登录错误2次 登录错误3次 登录错误3次 登录错误4次 登录错误4次
还有一个问题 if (user.getPwdCount()>pwdCount)中pwdCount为3时 还出现登录错误次数为4.
这后面还应该有个else把,当你登陆错误,并且错误次数小于你定义的次数的时候,你的把错误次数+1之后再放入到系统!
user.setUserState(1);
DAOFactory. getInstance().getUserDAO().modify(user);
errors.add( "error_checkCode",
new ActionError("error.loginForm.checkCode.error" ));
saveErrors(httpServletRequest, errors);
return actionMapping.getInputForward();
}else{
user.setPwdCount(user.getPwdCount() + 1);
DAOFactory. getInstance().getUserDAO().modify(user);
httpServletRequest.setAttribute( "pwdCount", String.valueOf(user.getPwdCount()));}但是还有错的~·
先把数据库里面的用户记录清除,之后再servlet里面设置断点,自己一步一步跟着数据走!
貌似也只有这简单原始的办法了!