[英]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
已经集成通过扩展Action类DomainBlockedListAction
是这样的:
public class DomainBlockedListAction extends DomainBlockForm
我需要在整个应用程序中结转表单值。 但是这些值仅在请求/页面范围内可用。 因此,对于Struts1到Struts2,我应该有一个scope =“ session”的替代方案,以便可以在整个应用程序中继承所有属性。
从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]
在Struts 2中,没有动作表单Bean,并且动作本身默认为请求上下文。 @meskobalazs在上面是正确的,如果您在Struts 2中需要会话作用域的操作,可以使用范围拦截器将其覆盖。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.