📄 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
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2005</p>
* <p>Company: IASPEC Technologies</p>
* @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");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -