反射机制的巧妙使用:getMethod()

JspWriter out=this.pageContext.getOut();
String actionType=memberActionBean.getMemberAction().getActionType();
Class[] cl=new Class[0];
Object[] args=new Object[0];
Method meth=null;
try{
meth=this.getClass().getMethod(actionType,cl);
}catch(Exception e){}
String str="";
if(meth!=null){
str=meth.invoke(this,args).toString();
}
out.print(str.toString());

你可能感兴趣的:(java)