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 ,