www.pudn.com > project.rar > LoginAction.java


package cn.com.iaspec.workflow.client.web.action.privilege; 
 
import javax.servlet.http.*; 
import org.apache.struts.action.*; 
import cn.com.iaspec.workflow.client.*; 
import cn.com.iaspec.workflow.client.web.action.base.*; 
import cn.com.iaspec.workflow.exception.*; 
import cn.com.iaspec.workflow.util.*; 
import cn.com.iaspec.workflow.vo.workflow.*; 
 
/** 
 * 登录action 
 * 

Title:

*

Description:

*

Copyright: Copyright (c) 2005

*

Company: IASPEC Technologies

* @author xiesonglin * @version 1.0 */ public class LoginAction extends BaseAction{ public LoginAction(){ } public ActionForward login(ActionMapping mapping,ActionForm form, HttpServletRequest request,HttpServletResponse response) throws Exception{ String loginName=request.getParameter("loginName"); String password=request.getParameter("password"); try{ WorkflowPrivilegeClient client=new WorkflowPrivilegeClient(); UserInfo userInfo=client.login(loginName,password); if(userInfo==null) throw new Exception("用户名或密码不正确"); //放在会话中 HttpSession session=request.getSession(false); userInfo.setSessionId(session.getId()); session.setAttribute(FlowWebKeys.USER_SESSION,userInfo); return mapping.findForward("main"); } //用户名不正确 catch(IncorrectLoginIdException ex){ logger.error(ex); ex.printStackTrace(); request.setAttribute("errorType","login_name_error"); request.setAttribute("errorMessage",ex.getMessage()); return mapping.findForward("index"); } //密码不正确 catch(IncorrectPasswordException ex){ logger.error(ex); ex.printStackTrace(); request.setAttribute("errorType","password_error"); request.setAttribute("errorMessage",ex.getMessage()); return mapping.findForward("index"); } catch(Exception e) { logger.error(e); e.printStackTrace(); request.setAttribute("errorType","password_error"); request.setAttribute("errorMessage",e.getMessage()); return mapping.findForward("index"); } } }