package com.manage.action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class UserAction extends ActionSupport {
private static final long serialVersionUID = 1L;
private String username;
private String password;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String execute() throws Exception {
return "login";
}
public String login() throws Exception {
String msg;
if ("test".equals(this.username) && "test".equals(this.password)) {
msg = "登录成功,欢迎" + this.username;
ActionContext context = ActionContext.getContext();
if (null != context.getSession().get("uName")) {
msg = this.username + ":您已经登录过了。";
} else {
context.getSession().put("uName", this.username);
}
return "success";
} else {
msg = "登录失败,用户名或密码错误。";
return "error";
}
}
}