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

📄 loginaction.java

📁 这是一个学校老师和学生的管理系统,程序比较简单,但是几乎所有功能都可以实现,如果想要用,只要再添加一些东西就可以了.
💻 JAVA
字号:
/**
 *******************************************************************************
 * LoginAction.java
 *
 * (c) Copyright 2008 Hewlett-Packard Development Company, L.P.
 *
 *<Program Content>
 *  System Name : Students Management System
 *<Summarize>
 *  The file includes a class and the class main function is to log in the 
 *  login page.
 *<Update Record>
 *  2009-4-27    1.00    zhangliy
 *******************************************************************************
 */
package com.hp.eds.zhangliyuan.stuMan.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.springframework.web.struts.ActionSupport;

import com.hp.eds.zhangliyuan.stuMan.consts.PageConsts;
import com.hp.eds.zhangliyuan.stuMan.dto.UserDto;
import com.hp.eds.zhangliyuan.stuMan.form.LoginForm;
import com.hp.eds.zhangliyuan.stuMan.service.interf.StudentServiceInt;

/**
 * The class main function is to log in the login page.
 * 
 * @author zhangliy
 * @version 1.0
 */
public class LoginAction extends ActionSupport {

	/**
	 * if the result is not null,go to the stuMenu page,else go back to the
	 * login page.
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 * @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping,
	 *      org.apache.struts.action.ActionForm,
	 *      javax.servlet.http.HttpServletRequest,
	 *      javax.servlet.http.HttpServletResponse)
	 */
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		// StudentServiceInterface service=SpringTool.getBean();
		HttpSession session = request.getSession();
		LoginForm loginForm = (LoginForm) form;
		UserDto userDto = new UserDto();
		userDto.setUserID(loginForm.getUserID());
		userDto.setPassword(loginForm.getPassword());
		StudentServiceInt studentService = (StudentServiceInt) this
		.getWebApplicationContext().getBean("studentServiceInt");
		userDto = studentService.getUserInfo(userDto);
		String forward = null;
		if (userDto != null) {
			forward = PageConsts.LOGIN_SUCCESS_PAGE;
			session.setAttribute(PageConsts.LOGIN_SUCCESS_SESSION_MASSAGE,
					userDto.getUser());
		} else {
			forward = PageConsts.LOGIN_FAILURE_PAGE;
			request.setAttribute(PageConsts.LOGIN_FAIL_REQUEST,
					PageConsts.LOGIN_FAIL_MESSAGE);
		}
		return mapping.findForward(forward);
	}
}

⌨️ 快捷键说明

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