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

📄 allcontrol.java

📁 仓库管理系统毕业设计论文最好的参考资料!
💻 JAVA
字号:
package com.qhit.sys;

import java.io.IOException;
import java.lang.reflect.Method;

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

public class AllControl extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		doPost(request, response);
	}

	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		String path = request.getServletPath();
		if(path.endsWith(".do")){
			path = path.substring(0, path.length()-3);
			path = path.replaceAll("/admin/", "/");
		}
		String packprefix = "com.qhit.action.";
		String className = packprefix + path.substring(1,path.indexOf("."));
		String methodName = path.substring(path.indexOf(".") + 1);
		
		try{
			Class cla = Class.forName(className);
			Object obj = cla.newInstance();
			
			//得到要执行的方法
			Method m = cla.getMethod(methodName, new Class[]{HttpServletRequest.class,HttpServletResponse.class});
			
			//方法执行
			m.invoke(obj, new Object[]{request,response});
		}catch(Exception e){
			e.printStackTrace();
			request.setAttribute("message", "执行出错,原因:" + e.getMessage());
		}
		
	}

}

⌨️ 快捷键说明

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