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

📄 adminloginservlet.java

📁 jsp+servlet+Hibernte实现的公务员网上报名系统。为大学毕业设计成果
💻 JAVA
字号:
package com.servlet;

import java.io.IOException;

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

import com.dao.AdminInfoDAO;
import com.dao.impl.AdminInfoDAOImpl;
import com.entity.AdminInfo;

public class AdminLoginServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;

	public AdminLoginServlet() {
		super();
	}

	public void destroy() {
		super.destroy(); 
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doPost(request,response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		request.setCharacterEncoding("gb2312");
	    response.setCharacterEncoding("gb2312");
	    
	//    String adminName = request.getParameter("adminName");
	    String adminPassword = request.getParameter("adminPassword");
	    int adminIndify = Integer.parseInt(request.getParameter("adminIndify"));
	    
	    AdminInfoDAO adminInfoDAOImpl = new AdminInfoDAOImpl();
	    AdminInfo adminInfo = adminInfoDAOImpl.queryAdmInfoByIndify(adminIndify);
	    String adminPasswordDB = adminInfo.getAdminPassword();
	    
	    if(adminPassword.equals(adminPasswordDB)){
	    	HttpSession session = request.getSession(true);
	    	session.setAttribute("adminInfo", adminInfo);
	    	session.setAttribute("isLogin", "true");
	    	
	    	request.getRequestDispatcher("/servlet/AdminPostsListServlet").forward(request, response);
	    }
	    
	}

	public void init() throws ServletException {
		
	}

}

⌨️ 快捷键说明

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