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

📄 controlservlet.java

📁 实现统一的人员日志管理系统管理后台
💻 JAVA
字号:
package com.tb.log.control;

import java.io.IOException;
import java.io.PrintWriter;

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

import com.tb.log.control.action.Action;
import com.tb.log.factory.ControlFactory;
import com.tb.log.system.SystemException;


public class ControlServlet extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public ControlServlet() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		this.doPost(request, response);
	}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String currentURI = request.getRequestURI();
		String path = currentURI.substring(currentURI.lastIndexOf("/")+1,currentURI.lastIndexOf("."));
//System.out.println(path);
		String forwardPath = "";
		
		try {
		if("login".equals(path)){
			Action model = ControlFactory.getAction("com.tb.log.control.action.LoginAction");
				forwardPath = model.execute(request, response);
			
		}
			if("dept".equals(path)){
				Action model = ControlFactory.getAction("com.tb.log.control.action.DeptAction");
				forwardPath = model.execute(request, response);
			}else if("log".equals(path)){
				Action model = ControlFactory.getAction("com.tb.log.control.action.LogAction");
				forwardPath = model.execute(request, response);
			}else if("pro".equals(path)){
				Action model = ControlFactory.getAction("com.tb.log.control.action.ProAction");
				forwardPath = model.execute(request, response);
			}else if("user".equals(path)){
				Action model = ControlFactory.getAction("com.tb.log.control.action.UserAction");
				forwardPath = model.execute(request, response);
			}
			
			if(forwardPath.equals("addDeptOK")){
				response.sendRedirect("");
			}else if(forwardPath.equals("addProOk")){
				response.sendRedirect("");
			}else if(forwardPath.equals("loginFailed")){
				response.sendRedirect("jsp/login/login.jsp");
			}else{
				request.getRequestDispatcher(forwardPath).forward( request, response);
			}
		} catch (SystemException e) {
			request.setAttribute("err", e);
			request.getRequestDispatcher("err.jsp").forward(request, response);
		}
		
		
	}

	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occurs
	 */
	public void init() throws ServletException {
		// Put your code here
	}

}

⌨️ 快捷键说明

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