package com.java1234.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts2.interceptor.ServletRequestAware;

import com.java1234.dao.ManagerDao;
import com.java1234.model.Manager;
import com.java1234.model.Student;
import com.opensymphony.xwork2.ActionSupport;

public class ManagerAction extends ActionSupport implements ServletRequestAware{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private HttpServletRequest request;
	
	private ManagerDao managerDao=new ManagerDao();
	
	private Manager manager;
	private String error;
	
	public Manager getManager() {
		return manager;
	}

	public void setManager(Manager manager) {
		this.manager = manager;
	}
	

	public String getError() {
		return error;
	}

	public void setError(String error) {
		this.error = error;
	}

	/**
	 * 登录验证
	 * @return
	 * @throws Exception
	 */
	public String login()throws Exception{
		HttpSession session=request.getSession();
		Manager currentUser=managerDao.login(manager);
		if(currentUser==null){
			error="用户名或者密码错误!";
			return ERROR;
		}else{
			session.setAttribute("currentUser", currentUser);
			return SUCCESS;
		}
	}
	
	/**
	 * 注销用户
	 * @throws Exception
	 */
	public String logout()throws Exception{
		request.getSession().invalidate();
		return "logout";
	}
	
	public void setServletRequest(HttpServletRequest request) {
		this.request=request;
	}

}
最近下载更多
weilaizhisheng  LV21 2023年9月16日
似鹤不是鹤似鹤不是鹤  LV1 2023年5月5日
sswert  LV2 2023年5月4日
amour1  LV11 2023年5月3日
tujf13763823976  LV3 2023年3月28日
fu8867  LV2 2023年2月20日
wubinbin  LV11 2023年2月11日
shamexidan  LV9 2022年5月20日
shibinf  LV3 2022年4月8日
and123456  LV11 2022年2月7日
最近浏览更多
pokerf  LV5 4月7日
taoshen95  LV14 2月29日
gjw19884260466  LV3 1月8日
WBelong  LV7 2023年12月11日
cpla1998  LV8 2023年11月28日
zhxhcj  LV8 2023年11月26日
hhhh别卷了 2023年10月20日
暂无贡献等级
186092  LV4 2023年9月20日
weilaizhisheng  LV21 2023年9月16日
暂无贡献等级
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友