⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 loginactionproxy.java

📁 企业管理信息系统 myeclipse+mysql+hibernate+struts
💻 JAVA
字号:
package com.emis.actionproxy;

import java.util.List;

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

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;

import com.emis.actionform.LoginActionForm;
import com.emis.dbservice.hibernate.HibernateService;
import com.emis.framework.IEmisActionProxy;
import com.emis.model.hr.hibernate.Employee;
import com.emis.web.exception.OperationLogicException;

public final class LoginActionProxy implements IEmisActionProxy {
	private ServletContext servletContext;
	
	public ServletContext getServletContext() {
		// TODO Auto-generated method stub
		return servletContext;
	}

	public ActionMessages service(ActionForm form, HttpServletRequest request)
			throws OperationLogicException {
		String id = null;
        String pwd = null;
        
        if (form != null) {
            id = ((LoginActionForm)form).getId();
            pwd = ((LoginActionForm)form).getPwd();
        }
        ActionMessages errors = new ActionMessages();
        HttpSession httpSession = request.getSession();
        List list = HibernateService.execQuery("from Employee where id=" + id + " and pwd=" + pwd);
        if (list == null || list.size() == 0) {
            errors.add("valid", new ActionMessage("errors.login.id.pwd.valid"));
        }
        else {
            httpSession.setAttribute("employee", (Employee)list.get(0));
        }
		return errors;
	}

	public void setServletContext(ServletContext ctx) {
		this.servletContext = ctx;
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -