📄 loginaction.java
字号:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.nitpro.action;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
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 org.apache.struts.actions.DispatchAction;
import com.nitpro.dao.DAOFactory;
/**
* MyEclipse Struts
* Creation date: 12-25-2007
*
* XDoclet definition:
* @struts.action validate="true"
*/
public class LoginAction extends DispatchAction {
/*
* Generated Methods
*/
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward login(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
DynaActionForm loginForm = (DynaActionForm)form;
String operator_id = (String)loginForm.get("operator_id");
String operator_pwd = (String)loginForm.get("operator_pwd");
DAOFactory dao = DAOFactory.getDAOFactory(DAOFactory.MYSQL);
HttpSession session = request.getSession();
int rst = dao.getAllMethodDAO().login(operator_id, operator_pwd);
if(rst == 1){
List mlist = dao.getAllMethodDAO().getMedicineType();
session.setAttribute("mlist", mlist);
return mapping.findForward("loginok");
}else if (rst == 2){
ActionErrors errors = new ActionErrors();
errors.add("operator_pwd", new ActionError("operatorPwdError"));
this.saveErrors(request, errors);
return mapping.getInputForward();
}else{
ActionErrors errors = new ActionErrors();
errors.add("operator_id", new ActionError("operatorIdError"));
this.saveErrors(request, errors);
return mapping.getInputForward();
}
}
public ActionForward loginOut(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
HttpSession session = request.getSession();
session.invalidate();
return null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -