package com.test.action;
import com.opensymphony.xwork2.ActionSupport;
public class LoginAction extends ActionSupport {
private String userName;
private String userPwd;
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getUserPwd() {
return userPwd;
}
public void setUserPwd(String userPwd) {
this.userPwd = userPwd;
}
public String execute() throws Exception
{
String userName = this.getUserName();
String userPwd = this.getUserPwd();
if("haha".equals(userName) && "111".equals(userPwd))
{
return "ok";
}
else
{
this.addFieldError("userName","用户名或密码错误!");
return "fail";
}
}
@Override
public void validate() {
if(null == this.getUserName() || "".equals(this.getUserName().trim()))
{
this.addFieldError("userName", "用户名不能为空");
}
if(null == this.getUserPwd() || "".equals(this.getUserPwd().trim()))
{
this.addFieldError("userPwd", "密码不能为空");
}
}
}
Struts2.0做的登陆
需积分: 0 24 浏览量
2008-06-15
13:19:10
上传
评论
收藏 3.21MB RAR 举报
lgc2848
- 粉丝: 1
- 资源: 8
评论0