Strutsz中 ActionForm工作原理

(1)检查Action的映射,确定Action中已经配置了对ActionForm的映射。

Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> <form-beans>
        <form-bean name="loginForm" type="#"></form-bean>
    </form-beans>
<!--两个name同名才行-->
       <action-mappings>
           <action path="#" type="#" name="loginForm" scope="request" validate="false">
               <forward name="#" path="#"></forward>
           </action>
       </action-mappings>

(2)根据name,查找form-bean配置信息。

(3)检查Action的form bean的使用范围,确定在此范围下(request、session)是否已有Form bean实例。

(4)如当前范围下已存在form bean实例,而对当前请求来说,是同一类型的话,就重用它。

(5)否则重新构建一个form bean实例,并且调用构造方法,保持在一定的范围。

(6)form bean的reset()方法被调用

(7)调用对应的setter方法,对状态属性赋值

(8)如validatede属性设为true,那么就调用form bean的validatede()方法(服务器校验)

(9)如validatede()没有返回任何bug,控制器将Actionform作为参数,传给Action实例的execute()方法并执行

工作流程图如下:

原文地址:https://www.cnblogs.com/qq1312583369/p/11245254.html