【www.gdgbn.com--Action】


Struts 学习笔记之Action
 
下面是Struts中的一些常用Action如DispatchAction/LookupDispatchAction/MappingDispatchAction/ForwardAction/IncludeAction的总结
 
1 .DispatchAction extends BaseAction
一般的Action如,在这里UserAction只需要继承父类(extends Action类),然后重写父类的execute方法,在execute中实现具体的控制转向。
对于同一个formbean上进行的新增、修改、删除等,我们需要分发不同的Action,这里有两种做法。
一种是通过在execute方法中if判断进行不同的转向:
㈠ UserAction 类的execute方法中
String method = request.getParameter("method");
if (method.equals("create")) {
     ……
    return mapping.findForward("createUser");
}
if (method.equals("save")) {
    ……
    return mapping.findForward("saveUser");
}
 
㈡ struts-config.xml 中:

        name="userForm"
        scope="request">
   

本文来源:http://www.gdgbn.com/flash/13361/