package com.dd.struts.actions;
import java.lang.reflect.Method;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
/*
* org.apache.struts.actions.DispatchAction;
* 类的低层实现
* */
public class DispachActions extends Action{
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
//获得struts_config.xml 配制文件action-mappings 里面的parameters 的value
String params = mapping.getParameter();
//通过params 获得界面上对应名称的value值
String method = request.getParameter(params);
//表示当前类对象.Servlet初始了哪个类就是哪个类的对象 在这里是 DispachActions的子类的对象
//不本类的对象
Class c = this.getClass();
Method mh = c.getMethod(method, new Class[]{ActionMapping.class,ActionForm.class,HttpServletRequest.class,HttpServletResponse.class});
Object obj = mh.invoke(this,mapping,form,request,response);
return (ActionForward) obj;
}
}
DispatchAction 简单的DispatchAction实现.不到的地方希望指点
struts_DispatchAction的实现
最新推荐文章于 2024-01-16 20:44:20 发布