登陆的action中execute代码:
Map mapsession = ActionContext.getContext().getSession();
String randcheck = (String) mapsession.get("validateCode");
mapsession.put("validateCode", null);
if (!randcheck.equals(check))
{
this.addFieldError("check", "验证码输入有误,请重新输入");
return INPUT;
}
if (loginService.userpass(username, password))
{
System.out.println("userpass returns true");
HttpServletRequest request = ServletActionContext.getRequest();
HttpSession session = request.getSession();
session.setAttribute("login", "vip");
this.setLogin((String) session.getAttribute("login"));
System.out.println("the values login in session is"+(String) session.getAttribute("login"));
return SUCCESS;
} else
{
this.addFieldError("username", "用户名或密码错误");
return INPUT;
}
Map mapsession = ActionContext.getContext().getSession();
String randcheck = (String) mapsession.get("validateCode");
mapsession.put("validateCode", null);
if (!randcheck.equals(check))
{
this.addFieldError("check", "验证码输入有误,请重新输入");
return INPUT;
}
if (loginService.userpass(username, password))
{
System.out.println("userpass returns true");
HttpServletRequest request = ServletActionContext.getRequest();
HttpSession session = request.getSession();
session.setAttribute("login", "vip");
this.setLogin((String) session.getAttribute("login"));
System.out.println("the values login in session is"+(String) session.getAttribute("login"));
return SUCCESS;
} else
{
this.addFieldError("username", "用户名或密码错误");
return INPUT;
}
Map session = ActionContext.getContext().getSession();
String randcheck = (String) session.get("validateCode");
session.put("validateCode", null);
if (!randcheck.equals(check))
{
this.addFieldError("check", "验证码输入有误,请重新输入");
return INPUT;
}
// 模拟生成密码
this.setAftermd5(this.username.substring(3, 6) + this.sex
+ this.password.substring(2, 4));
if (regist2Service.insertUser(username, password, email, sex, keyword,
realname, tel, re, years, months, days,check))
{
return SUCCESS;
} else
return ERROR;
这怎么操作??
是在服务器端清楚??
2 第二次登陆一定要重新生成验证码
3 第二次当然也需要输入验证码OVER
set方法还是执行了