DynaActionForm和 和有什么不一样ActionForm?
有人说DynaActionForm这不是真正的动态,因为您在重新配置文件中的属性后仍然需要重新启动服务器struts-config.xml(否则修改不会被拾取)
DynaActionForm和 和有什么不一样ActionForm?
有人说DynaActionForm这不是真正的动态,因为您在重新配置文件中的属性后仍然需要重新启动服务器struts-config.xml(否则修改不会被拾取)
的情况下ActionForm,
我们必须提供setters以及getters每当用户添加控件时。当用户创建视图时,同样的过程会一次又一次地重复。
但是,万一DynaActionForm
它消除了这种负担并创建了表单 bean 本身。这样用户就不必编写settersand了getters。不需要 bean 类DynaActionForm,我们将表单 bean 声明为DynaActionFormin 类型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>
更新
struts-config.xml有两个部分:form-beans部分,列出 ActionForm bean 和action-mappings。请求 (MyActionForm.do) 到特定 Action 和 ActionForm 类的映射在 struts-config.xml 文件中完成。