📄 loginaction.java
字号:
/**
* (c) Copyright 2007 computer01
*
* FILENAME : LoginAction.java
* PACKAGE : com.computer03.action
* CREATE DATE : 2007-12-26
* AUTHOR : admin
* DESCRIPTION : LoginAction Servlet
*/
package com.computer03.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.computer03.common.SessionInfo;
import com.computer03.entity.AllEntity;
import com.computer03.entity.TAB_STUDENTS;
import com.computer03.entitysupport.StudentsAssiImpl;
public class LoginAction extends HttpServlet{
private static final long
serialVersionUID = -2854114320143909334L;
public void doGet(HttpServletRequest request
,HttpServletResponse response)
throws ServletException,IOException{
//获取数据
String uid =
request.getParameter("uid");
String pwd =
request.getParameter("pwd");
//封装数据
TAB_STUDENTS stucon = new TAB_STUDENTS();
stucon.setSTUNO(uid);
AllEntity condition = new AllEntity();
condition.setStudent(stucon);
//验证数据
StudentsAssiImpl impl =
new StudentsAssiImpl();
List list =
impl.getEntityList(condition);
PrintWriter out = response.getWriter();
if(list!=null){
if(list.size()!=0){//用户存在
AllEntity allget =
(AllEntity)list.get(0);
TAB_STUDENTS stuget =
allget.getStudent();
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{//用户名存在,密码不正确
out.write("uid be ,pwd error!!!");
}
}else{//用户不存在
out.write("user's info not exists!");
}
}else{//用户不存在
out.write("user's info not extist!");
}
}
public void doPost(HttpServletRequest request
,HttpServletResponse response)
throws ServletException,IOException{
doGet(request,response);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -