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

📄 loginaction.java

📁 学校期间做的实践项目
💻 JAVA
字号:
/**
 *  (c) Copyright 2007 computer01
 *
 *   FILENAME     :  LoginAction.java
 *   PACKAGE      :  com.computer01.action
 *   CREATE DATE  : 2007-12-24
 *   AUTHOR       :  admin
 *   DESCRIPTION  :  登录系统Action Servlet
 */
package com.computer01.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.computer01.common.SessionInfo;
import com.computer01.entity.AllEntity;
import com.computer01.entity.TAB_STUDENTS;
import com.computer01.entitysuport.StudentsAssiImpl;

public class LoginAction extends HttpServlet{

	/**
	 * 序列化
	 */
	private static final long 
	serialVersionUID = -95225605051541092L;
	/**
	 * doGet 方法
	 */
	public void doGet(HttpServletRequest request
			,HttpServletResponse response)
	throws ServletException,IOException{
		/** 获取登录数据*/
		String uid = request.getParameter("uid");
		String pwd = request.getParameter("pwd");
		/**验证用户名及密码*/
		TAB_STUDENTS stu = new TAB_STUDENTS();
		stu.setSTUNO(uid);
		stu.setPWD(pwd);
		AllEntity condition =
			new AllEntity();
		condition.setTabstudents(stu);
		/**查询*/
		StudentsAssiImpl impl =
			 new StudentsAssiImpl();
		List alentilist = 
			impl.getEntityList(condition);
		if(alentilist !=null&&
				alentilist.size() != 0){
			AllEntity allentiget =
				(AllEntity)alentilist.get(0);
			TAB_STUDENTS stuget =
				allentiget.getTabstudents();
			if(pwd.equals(stuget.getPWD())){
				/**
				 * 将用户信息放入Session中
				 */
				SessionInfo sessinfo =
					new SessionInfo();
				sessinfo.setCurrstu(stuget);
				request.getSession().setAttribute("SessionInfo", sessinfo);
				//登录成功
			response.sendRedirect(
					request.getContextPath()
					+"/web/frame/mainframe.jsp");
			}else{
				response.sendRedirect(
						request.getContextPath()
						+"/web/jsp/common/errorpage/loginerror.jsp");
			}
		}else{
			//登录不成功,转向错误处理页面
			response.sendRedirect(
			request.getContextPath()
			+"/web/jsp/common/errorpage/loginerror.jsp");
		}
	}
	/**
	 * doPost 方法
	 */
	public void doPost(HttpServletRequest request
			,HttpServletResponse response)
	throws ServletException,IOException{
		doGet(request,response);
	}
}

⌨️ 快捷键说明

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