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

📄 loginaction.java

📁 基本分数查询功能,自己的毕业设计作品!希望能给大家一点帮助!
💻 JAVA
字号:
package org.xk.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import org.xk.form.AdminForm;
import org.xk.form.PortForm;
import org.xk.form.StudentForm;
import org.xk.form.TeacherForm;
import org.xk.po.AdminUser;
import org.xk.po.PortUser;
import org.xk.po.StudentUser;
import org.xk.po.TeacherUser;
import org.xk.util.ServiceUtil;

public class LoginAction extends DispatchAction{
	public ActionForward adminLogin(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		AdminForm af = (AdminForm) form;

		if (ServiceUtil.getUserService().isAdminLogin(af.getAdmin_user(),
				af.getAdmin_password())) {
			HttpSession session = request.getSession();
			session.setAttribute("admin", (AdminUser) ServiceUtil
					.getUserService().getAdminInfo(af.getAdmin_user(),
							af.getAdmin_password()));
			session.setMaxInactiveInterval(-1);
			request.setAttribute("msg", "登录成功,系统将在两秒后自动转到页面");
			request.setAttribute("gowhere", "../admin/admin_index.jsp");
		} else {
			request.setAttribute("msg", "登录失败,请检查你的用户名和密码后重新登录");
			request.setAttribute("gowhere", "./admin_user.jsp");
		}

		return mapping.findForward("go");

	}
	
	public ActionForward studentLogin(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		StudentForm sf = (StudentForm) form;

		if (ServiceUtil.getUserService().isStudentLogin(sf.getStu_user(),
				sf.getStu_password())) {
			HttpSession session = request.getSession();
			session.setAttribute("user", (StudentUser) ServiceUtil
					.getUserService().getStudentInfo(sf.getStu_user(),
							sf.getStu_password()));
			session.setMaxInactiveInterval(-1);
			request.setAttribute("msg", "登录成功,系统将在两秒后自动转到页面");
			request.setAttribute("gowhere",
					"../studentmanager/student_index.jsp");
		} else {
			request.setAttribute("msg", "登录失败,请检查你的用户名和密码后重新登录");
			request.setAttribute("gowhere", "./student_user.jsp");
		}

		return mapping.findForward("go");

	}
	
	public ActionForward teacherLogin(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		TeacherForm tf = (TeacherForm) form;
       int port_id=Integer.parseInt(request.getParameter("port_id"));
		if (ServiceUtil.getUserService().isTeacherLogin(tf.getTeacher_user(),
				tf.getTeacher_password(),port_id)) {
			HttpSession session = request.getSession();
			session.setAttribute("teacher", (TeacherUser) ServiceUtil
					.getUserService().getTeacherInfo(tf.getTeacher_user(),
							tf.getTeacher_password()));
			session.setMaxInactiveInterval(-1);
			request.setAttribute("msg", "登录成功,系统将在两秒后自动转到页面");
			request.setAttribute("gowhere",
					"../teachermanager/teacher_index.jsp");
		} else {
			request.setAttribute("msg", "登录失败,请检查你的用户名和密码后重新登录");
			request.setAttribute("gowhere", "./teacher_user.jsp");
		}

		return mapping.findForward("go");

	}
	
	public ActionForward portLogin(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		PortForm pf = (PortForm) form;

		if (ServiceUtil.getUserService().isPortLogin(pf.getPort_number())) {
			HttpSession session = request.getSession();
			session.setAttribute("port", (PortUser) ServiceUtil
					.getUserService().getPortInfo(pf.getPort_number()));
			session.setMaxInactiveInterval(-1);
			request.setAttribute("msg", "端口号正确,系统将在两秒后自动转到页面");
			request.setAttribute("gowhere", "./teacher_user.jsp");
		} else {
			request.setAttribute("msg", "端口号错误,请重新输入");
			request.setAttribute("gowhere", "./port_user.jsp");
		}

		return mapping.findForward("go");

	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -