【Java开源代码栏目提醒】:网学会员在Java开源代码频道为大家收集整理了AdminLoginAction.java提供大家参考,希望对大家有所帮助!
package com.org.action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.org.service.*;
import java.util.*;
public class AdminLoginAction extends ActionSupport
{
private String username;
private String password;
private AdminUserControl adUserControl;
public void setAdUserControl(AdminUserControl adUserControl)
{
this.adUserControl = adUserControl;
}
public String execute() throws Exception
{
Map session = ActionContext.getContext().getSession();
boolean returnCode=adUserControl.validNamandPass(username, password);
if (returnCode==true)
{
session.put("adminname" , getUsername());
return SUCCESS;
}
else
{
addActionError("用户名/密码不匹配");
return "failure";
}
}
public void validate()
{
if (getUsername() == null || getUsername().trim().equals(""))
{
addFieldError("username", "用户名不能为空");
}
if (getPassword() == null || getPassword().trim().equals(""))
{
addFieldError("password", "密码不能为空");
}
}
public void setUsername(String username)
{
this.username = username;
}
public String getUsername()
{
return this.username;
}
public void setPass
word(String password)
{
this.password = password;
}
public String getPassword()
{
return this.password;
}
}