67,513
社区成员
发帖
与我相关
我的任务
分享
<action
attribute="adminLogonForm"
input="/admin/login.jsp"
name="adminLogonForm"
path="/adminLogon"
scope="request"
type="com.info.job.action.AdminLogonAction">
<forward
name="success"
path="/admin/main.jsp"
redirect="true" />
<forward
name="failure"
path="/admin/error.jsp"
redirect="true" />
//验证输入的验证码是否正确,不正确返回出错信息
if (incode.equals(code)) {
//调用checkManager()方法验证用户名及密码合法性,不正确返回出错信息
if (dboper.checkManager(username, password)) {
return mapping.findForward("success");
} else {
errors.add("name", new ActionMessage("login.error"));
saveErrors(request, errors);
return mapping.findForward("failure");
}
} else {
errors.add("coderror", new ActionMessage("vertifycode.error"));
saveErrors(request, errors);
return mapping.findForward("failure");
}
<html:html lang="true">
<head>
<html:base />
<title>登陆错误</title>
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body><center><html:errors></html:errors></center>
</body>
</html:html>
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
// TODO Auto-generated method stub
ActionErrors errors = new ActionErrors();
//服务器端验证
if (this.username==null || "".equals(this.username))
{
errors.add("username", new ActionMessage("username.null"));
}
if (this.password==null || "".equals(this.password))
{
errors.add("password", new ActionMessage("password.null"));
}
return errors;
}