[英]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.