范围属性从 Struts1 迁移到 Struts2
Scope attribute migration from Struts1 to Struts2
我正在将应用程序从 Struts1 迁移到 Struts2。我可以从 Struts1 配置文件 (struts-config.xml
).
的以下操作标记中迁移除 scope
属性之外的所有内容
Struts1配置:
<action path="/DomainAndIPBlocking"
type="com.tarangtech.da.struts.action.DomainBlockedListAction"
name="DomainBlockForm"
scope="session"
input="/DomainAndIPBlocking.do"
validate="false">
<forward name="success" path="/jsp/SystemAdminConsol/DomainBlocking.jsp"/>
</action>
已迁移 Struts2 配置:
<action name="DomainAndIPBlocking"
class="com.tarangtech.da.struts.action.DomainBlockedListAction"
method="execute">
<result name="success">/jsp/SystemAdminConsol/DomainBlocking.jsp</result>
</action>
表单 DomainBlockForm
已通过扩展操作 class DomainBlockedListAction
集成,如下所示:
public class DomainBlockedListAction extends DomainBlockForm
我需要在整个应用程序中传递表单值。但是这些值仅在 request/page 范围内可用。
所以,我应该有一个 scope="session" 的替代方案,从 Struts1 到 Struts2,这样我就可以在整个应用程序中继承所有属性.
来自动作元素定义中的 Struts 1 DTD:
scope The context ("request" or "session") that is used to
access our ActionForm bean, if any. Optional if "name" is
specified, else not valid. [session]
在Struts2中,没有Action Form beans,Actions本身默认为request context。 @meskobalazs 在上面是正确的,如果你需要在 Struts 2.
中的会话范围内的操作,这可以用范围拦截器覆盖
我正在将应用程序从 Struts1 迁移到 Struts2。我可以从 Struts1 配置文件 (struts-config.xml
).
scope
属性之外的所有内容
Struts1配置:
<action path="/DomainAndIPBlocking"
type="com.tarangtech.da.struts.action.DomainBlockedListAction"
name="DomainBlockForm"
scope="session"
input="/DomainAndIPBlocking.do"
validate="false">
<forward name="success" path="/jsp/SystemAdminConsol/DomainBlocking.jsp"/>
</action>
已迁移 Struts2 配置:
<action name="DomainAndIPBlocking"
class="com.tarangtech.da.struts.action.DomainBlockedListAction"
method="execute">
<result name="success">/jsp/SystemAdminConsol/DomainBlocking.jsp</result>
</action>
表单 DomainBlockForm
已通过扩展操作 class DomainBlockedListAction
集成,如下所示:
public class DomainBlockedListAction extends DomainBlockForm
我需要在整个应用程序中传递表单值。但是这些值仅在 request/page 范围内可用。 所以,我应该有一个 scope="session" 的替代方案,从 Struts1 到 Struts2,这样我就可以在整个应用程序中继承所有属性.
来自动作元素定义中的 Struts 1 DTD:
scope The context ("request" or "session") that is used to
access our ActionForm bean, if any. Optional if "name" is
specified, else not valid. [session]
在Struts2中,没有Action Form beans,Actions本身默认为request context。 @meskobalazs 在上面是正确的,如果你需要在 Struts 2.
中的会话范围内的操作,这可以用范围拦截器覆盖