⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 indexaction.java

📁 这是一个用Struts+Hibernate+Tomcat5.5.9实现的一个“课程管理系统”
💻 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 + -