1.Action
action=new Action();//类例化一个对象
Method method =
action.getClass().getMethod(methodName,
method
parameterTypes
args:传入的参数
2.
Class[] cargs = new Class[1];2)new当前类(这个是借鉴,不过这个可以直接看结果哦)
import
public
} 3.项目中写到的: if(action.startsWith("dispatch")){
dipatchMethodName = mainDispatch.filter(action);
System.out.println("===========dipatchMethodName:"+dipatchMethodName);
parameterTypes[0]=HttpServletRequest.class;
parameterTypes[1]=HttpServletResponse.class;
Method method =
businessAction.getClass().getMethod(dipatchMethodName,
parameterTypes);
forward = (Boolean) method.invoke(businessAction,
req,resp);
} |
|