📄 login.java
字号:
package com.soft.login.control;
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.soft.deptmgr.dao.DeptInfoDAO;
import com.soft.login.dao.UserInfoDAO;
import com.soft.pagecut.pagecutbean;
import com.soft.vo.LoginInfo;
import com.soft.vo.RoleInfo;
public class Login extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request,response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
int employeeid;
String username = request.getParameter("username");
try{
employeeid=Integer.parseInt(username);
}
catch(Exception e)
{
employeeid=1100;
}
String password = request.getParameter("password");
UserInfoDAO uif = new UserInfoDAO ();
//DeptInfoDAO dif=new DeptInfoDAO();
System.out.println(employeeid);
if(uif.checkUserSQLInjection(employeeid, password))
{
List loginUserList=uif.getLoginUserInfo(employeeid);
List empList=uif.getEmpInfo();
List roleList=uif.searchRole(employeeid);
// List deptList=dif.getAllDepts();
for(int i =0;i<loginUserList.size();i++)
{
LoginInfo li = (LoginInfo)loginUserList.get(i);
request.getSession().setAttribute("departmentname",li.getDepartmentname());
request.getSession().setAttribute("position",li.getPosition());
request.getSession().setAttribute("name",li.getName());
request.getSession().setAttribute("employeeid",li.getEmployeeid());
request.getSession().setAttribute("password", password);
}
System.out.println("empList:"+empList.size()+"loginUserList:"+loginUserList.size()+"deptList");
request.getSession().setAttribute("empList", empList);
request.getSession().setAttribute("roleList",roleList);
request.getSession().setAttribute("flag","flag");
System.out.println("roleList:"+roleList.size());
request.getRequestDispatcher("gensystem.jsp").forward(request,response);
}
else
{
request.getRequestDispatcher("index.jsp").forward(request,response);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -