将 DynaActionForm 迁移到 Struts2

Migrating DynaActionForm to Struts2

从 Struts1 迁移到 Struts2 时,我遇到了 DynaActionForm。请提供代码片段作为示例,这将有助于转换为 Struts2。 尝试了很多 google 搜索但没有成功!

Struts2 中没有 DynaActionForm。如果您想动态设置属性,请使用 Map

Map<String, Object> dynaActionForm;
//getter and setter here

...

dynaActionForm.put("property1", object1.getProperty1());
dynaActionForm.put("property2", object2.getProperty1());

在 JSP 您可以访问此属性

<s:property value="dynaActionForm.property1"/>
<s:property value="dynaActionForm.property2"/>