package action;
import com.opensymphony.xwork2.ActionSupport;
import dao.imp.UserInfoImpl;
import entity.User;
public class LoginAction extends ActionSupport {
private UserInfoImpl userInfo ;
private int id;
private String username;
private String password;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
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 UserInfoImpl getUserInfo() {
return userInfo;
}
public void setUserInfo(UserInfoImpl userInfo) {
this.userInfo = userInfo;
}
@Override
public void validate() {
if ("".equals(username) || "".equals(password)) {
this.addFieldError("username", "请输入有效参数");
}
}
@Override
public String execute() throws Exception {
User user = new User();
user.setUsername(username);
user.setPassword(password);
if (null == userInfo.check(user)) {
return this.ERROR;
}
return super.SUCCESS;
}
}