//.... Action .......... Struts 2 .. Action ..
public class LoginAction implements Action
{
//...... Action ................................
private String username;
private String password;
//username .......... getter ....
public String getUsername()
{
return username;
}
//username .......... setter ....
public void setUsername(String username)
{
this.username = username;
}
//password .......... getter ....
public String getPassword()
{
return password;
}
//password .......... setter ....
public void setPassword(String password)
{
this.password = password;
}
//.............. execute ....
public String execute() throws Exception
{
//................ username .... scott................ tiger ........ success ..
....
//........ error ........
if (getUsername().equals("scott")
&& getPassword().equals("tiger") )
{
//.... ActionContext ........ Web ...... Session
ActionContext.getContext().getSession().put("user" , getUsername());
return SUCCESS;
}
else
{
return ERROR;
}
}
}
struts2 demo project
需积分: 9 135 浏览量
2009-01-13
11:02:36
上传
评论
收藏 3.21MB RAR 举报
Forsun0911
- 粉丝: 0
- 资源: 7