📄 loginaction.java
字号:
package com.action;
import org.apache.struts2.ServletActionContext;
import com.service.LoginCheck;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class LoginAction extends ActionSupport {
private String uname;
private String upassword;
private LoginCheck lc;
// 获得uname值
public String getUname() {
return uname;
}
// 设置uname值
public void setUname(String uname) {
this.uname = uname;
}
// 获得password值
public String getUpassword() {
return upassword;
}
// 设置password值
public void setUpassword(String upassword) {
this.upassword = upassword;
}
public void setLc(LoginCheck lc) {
this.lc = lc;
}
public String execute() throws Exception {
// 调用业务逻辑组件来判断
if (lc.isLogin(getUname(), getUpassword())) {
// 如果为合法用户,在session范围中添加属性login,其属性值为true,
ActionContext.getContext().getSession().put("login", "true");
return SUCCESS;
} else {
return ERROR;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -