📄 indexaction.java
字号:
//Created by MyEclipse Struts// XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_4.0.0/xslt/JavaClass.xslpackage struts.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 struts.*;import hibernate.*;import struts.form.AddStudentForm;import struts.form.IndexForm;/** * MyEclipse Struts Creation date: 11-12-2005 * * XDoclet definition: * * @struts.action path="/index" name="IndexForm" input="/index.jsp" * scope="request" validate="true" */public class IndexAction extends Action { // --------------------------------------------------------- Instance // Variables // --------------------------------------------------------- Methods public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { IndexForm indexForm = (IndexForm) form; String username = ""; String password = null; String kind=null; String pd=""; ActionMessages errors = new ActionMessages(); if (indexForm != null) { username = indexForm.getUsername(); password = indexForm.getPassword(); kind = indexForm.getKind(); pd = HibernateUtil.findPassword(username); } //pd = HibernateUtil.findPassword("luo"); HttpSession session = request.getSession(); if ((pd.equals(password)) && (pd != "")&&(pd!=null)) { session.setAttribute("username", username); } else { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage( "error.password.required")); } if (!errors.isEmpty()) { saveErrors(request, errors); return (new ActionForward(mapping.getInput())); } if (mapping.getAttribute() != null) { if ("request".equals(mapping.getScope())) request.removeAttribute(mapping.getAttribute()); else session.removeAttribute(mapping.getAttribute()); } if(kind.equals("teacher")){ return (mapping.findForward(Constants.TEACHER_SUCCESS)); } if(kind.equals("student")){ return (mapping.findForward(Constants.STUDENT_SUCCESS)); } return (mapping.findForward(Constants.ADMIN_SUCCESS)); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -