反射

String methodName = req.getParameter("method");

//获取类
Class calzz = this.getClass();

//获取方法

methodName 方法名 HttpServletRequest.class ,HttpServletResponse.class参数类型的字节流
Method method = calzz.getMethod(methodName, HttpServletRequest.class,HttpServletResponse.class);

//调用方法
method.invoke(this, req,res);

posted @ 2019-04-26 09:58  xing001  阅读(118)  评论(0编辑  收藏  举报