loginaction.java

来自「开发的一个java web的任务管理系统。」· Java 代码 · 共 60 行

JAVA
60
字号
/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package unicom.action;

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

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.DynaActionForm;

import unicom.bean.Operator;
import unicom.factory.ServiceFactory;
import unicom.service.IOperService;

/** 
 * 
 * @author 陈才旭
 * 功能:根据不同的操作权限,进行权限过滤,跳转到不同的操作主界面
 * 
 *
 */
public class LoginAction extends Action {

	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		DynaActionForm dyForm = (DynaActionForm)form;
		Operator oper = new Operator();
		oper.setName((String)dyForm.get("user"));
		oper.setPwd((String)dyForm.get("pwd"));
	
		//通过静态工厂方法获得业务bean,判断是否存在该操作用户
		IOperService operService = ServiceFactory.createOperService();
		HttpSession session = request.getSession(true);
		if(operService.checkOper(oper))
		{
			if(operService.isAdmin(oper))
			{
				
				session.setAttribute("admin", oper);
				return mapping.findForward("mainAdmin");
				
			}
			else{
				session.setAttribute("oper", oper);
				return mapping.findForward("mainoper");
			}
		}else{
			request.setAttribute("msg", "请输入正确的用户名或密码");
			return mapping.findForward("index");
			
		}
		
	}
}

⌨️ 快捷键说明

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