DynaActionForm和ActionForm有什么区别?

Joe*_*ang 2 java struts actionform struts-config

DynaActionForm和之间有什么区别ActionForm

有人说DynaActionForm不是真的动态,因为在重新配置struts-config.xml文件中的属性后仍然需要重新启动服务器(否则将不会修改修改)

Rav*_*avi 6

在这种情况下ActionForm,

我们必须提供settersgetters每当用户将控制.当用户创建视图时,会一次又一次地重复相同的过程.

但是,如果是的话 DynaActionForm

它消除了这种负担并创建了表单bean本身.这样,用户就不必写settersgetters.不需要bean类DynaActionForm,我们将表单bean声明为DynaActionForm类型struts-confing.xml.我们将在中声明属性及其类型struts-config.xml

   <?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE struts-config PUBLIC
 "-//Apache Software Foundation//DTD Struts Configuration 1.0//EN"
 "http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd">

<struts-config>

  <!-- ========== Form Bean Definitions ================= -->
  <form-beans>

    <form-bean      name="submitForm"
                    type="hansen.playground.SubmitForm"/>

  </form-beans>

  <!-- ========== Action Mapping Definitions ============ -->
  <action-mappings>

    <action   path="/submit"
              type="hansen.playground.SubmitAction"
              name="submitForm"
              input="/submit.jsp"
              scope="request">
    <forward name="success" path="/submit.jsp"/>          
    <forward name="failure" path="/submit.jsp"/>          
    </action>

  </action-mappings>

</struts-config>
Run Code Online (Sandbox Code Playgroud)

更新

struts-config.xml有两个部分:form-b​​eans部分,列出ActionForm bean,以及action-mappings.请求(MyActionForm.do)到特定的Action和ActionForm类的映射是在struts-config.xml文件中完成的.