DynaActionForm和ActionForm有什么区别?
有人说DynaActionForm并不是真正的动态,因为在重新配置了struts-config.xml文件中的属性之后,仍然需要重新启动服务器(否则修改将不会被获取)。
发布于 2012-12-16 06:31:16
在ActionForm,的情况下
当用户添加控件时,我们必须提供setters、和 getters 。当用户创建视图时,重复重复相同的进程。
但是,如果是DynaActionForm
它消除了这个负担,并创建了表单bean本身。这样,用户setters就不必编写、getters**.、和,DynaActionForm不需要bean类,我们将在struts-confing.xml中将表单bean声明为DynaActionForm**类型。我们将在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>更新
action-mappings.The有两个部分:列出ActionForm bean的form- beans 部分,请求(
MyActionForm.do)到特定操作和ActionForm类的struts-config.xml映射是在struts-config.xml文件中完成的。
https://stackoverflow.com/questions/13899112
复制相似问题