📄 logonaction.java
字号:
/*
* 僔僗僥儉丂丂丗 嶳廏HR僔僗僥儉奐敪
* 僒僽僔僗僥儉丗 WEB僔僗僥儉
*
* VER 丂曄峏擔 丂晹壽 扴摉幰 丂曄峏撪梕
* -----------------------------------------------------------------
* V1.00 丂丂${date} (ShanXiu丂Soft) Tuwenjie 弶斉
*
* (C) Copyright SHANXIU CORPORATION 2006
* All Rights Reserved.
*
*/
package net.shanxiu.HR.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.util.MessageResources;
import net.shanxiu.HR.actionform.LogonActionForm;
import net.shanxiu.HR.entity.Constants;
import net.shanxiu.HR.vo.Worker;
import net.shanxiu.HR.service.LogonActionService;
/******************************************************************************
* 僋儔僗偺奣梫丗logon system action
*
* @author 嶌惉幰 tuwenjie
* @version 1.0
*******************************************************************************
*/
public final class LogonAction extends Action {
/**
* Process the specified HTTP request, and create the corresponding HTTP
* response (or forward to another web component that will create it).
* Return an <code>ActionForward</code> instance describing where and how
* control should be forwarded, or <code>null</code> if the response has
* already been completed.
*/
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
// These "messages" come from the ApplicationResources.properties file
MessageResources messages = getResources(request);
/*
* Validate the request parameters specified by the user
* Note: Basic field validation done in LogonActionForm.java
* Business logic validation done in LogonAction.java
*/
ActionMessages errors = new ActionMessages();
String userId = (String)((LogonActionForm) form).getId();
String userPsw = (String)((LogonActionForm) form).getPsw();
LogonActionService logonActionService = new LogonActionService();
Worker worker = logonActionService.search(userId,userPsw);
// String emptyInf = "worker not exist:" + userId;
if (worker.getGuard().equals(Constants.OTHER)) {
errors.add("ActionMessages.GLOBAL.ERROR", new ActionMessage("title.logon.worker.notexist"));
saveErrors(request, errors);
return (new ActionForward(mapping.getInput()));
}
HttpSession session = request.getSession();
session.setAttribute(Constants.USER , worker);
if(worker.getGuard().equals(Constants.EMPLOYER)){
/*
* This is general employer
*/
return (mapping.findForward("main")) ;
}
// Forward control to the adminstrator URI
else
return (mapping.findForward("m_main"));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -