Struts1.x中的Action的问题,在线等?????

来源:百度知道 编辑:UC知道 时间:2024/05/13 02:34:53
关于继承哪个类的问题,

public class dads extends MappingDispatchAction {

@Override
public ActionForward execute(ActionMapping arg0, ActionForm arg1, HttpServletRequest arg2, HttpServletResponse arg3) throws Exception {
// TODO Auto-generated method stub
return super.execute(arg0, arg1, arg2, arg3);
}

*************************

public class dasds extends Action {

@Override
public ActionForward execute(ActionMapping arg0, ActionForm arg1, HttpServletRequest arg2, HttpServletResponse arg3) throws Exception {
// TODO Auto-generated method stub
return super.execute(arg0, arg1, arg2, arg3);
}

}

问题:继承了MappingDispatchAction和继承了Action有什么区别吗??

直接继承Action的默认执行execute方法。不能在带个参数method="..."了。如果你这样写了,你就只能action="/.....do"了。 一个action只能做一件事了。

MappingDispatchAction 是比DispatchAction更高级的类
如果楼主懂怎么用DispatchAction那就容易理解了
在配置文件中
<action path="这里是你要处理的请求" type="Action的类型" name="你要用到的FormBean" parameter="method" >
<forward name="别名 path="/index.jsp(相应的JSP)" />
</action>
如果这样写的话,可以这样 action="/xxx.do?method=xxxx"
就是一个action能做好多事。

不知道这样说你懂不懂。

MappingDispatchAction类也继承了Action类,因此dasds 继承哪个并无太大的区别18314974
有问题QQ:281876290 群:18314974