当前位置:编程学习 > JAVA >>

action里边的登录方法

public class AdminAction extends BaseAction {


// 当前Action涉及到业务对象
private AdminService adminService;

private Admin admin;


public void setAdminService(AdminService adminService) {
this.adminService = adminService;
}


public Admin getAdmin() {
return admin;
}


public void setAdmin(Admin admin) {
this.admin = admin;
}


public String login() {
System.out.println("login………………" + admin.getName() + "---"
+ admin.getPass());
if (ServletActionContext.getRequest().getSession()
.getAttribute("logadmin") != null) {
return "loginIn";
}
if (admin == null) {
return "loginOut";
}
admin = adminService.login(admin.getName(), admin.getPass());
System.out.println(admin);
// System.out.println(admin + "======");
ServletActionContext.getRequest().getSession()
.setAttribute("logadmin", admin);
return "loginIn";


}


public String logout() {


if (ServletActionContext.getRequest().getSession()
.getAttribute("logadmin") != null) {
ServletActionContext.getRequest().getSession()
.removeAttribute("logadmin");
}


return "loginOut";

补充:web前端 , JavaScript ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,