簡體   English   中英

在將 Struts 1 遷移到 Struts 2 時,Struts 2 中的 FormTag class 缺少 getOnsubmit 方法

[英]While migrating Struts 1 to Struts 2, the FormTag class in Struts 2 is missing a getOnsubmit method

我正在執行 Struts 1 到 Struts 2 的遷移。 我們有 Struts 1 代碼,它擴展和定制了org.apache.struts.taglib.html.FormTag Did some search and found that the org.apache.struts2.views.jsp.ui.FormTag is the equivalent in Struts2.

我當前的 Struts 1 代碼通過調用setOnsubmit()來修改FormTagonsubmit變量,但它通過首先執行如下所示的getOnsubmit()來實現。

    if (this.getOnsubmit() == null) {
        this.setOnsubmit(subCmd + subCmdEnd);
    }
    else {
        this.setOnsubmit(subCmd + this.getOnsubmit() + subCmdEnd);
    }

Struts 2 class 有setOnsubmit() ,但沒有getOnsubmit() 我們還有其他選項可以讀取onsubmit值嗎?

<s:form>標簽屬於 Struts 2 核心標簽庫。 So, if you need to use your own tag that extends this one then you should extend org.apache.struts2.views.jsp.ui.FormTag class and provide your own implementation by overriding public methods, and adding additional methods. onsubmit字段有一個protected的修飾符。

但在對 Struts 2 框架進行任何更改之前,請咨詢合格專家的建議:為什么需要這樣做? 為了將舊代碼帶到新代碼? 為 S1 編寫的代碼與 S2 不兼容。

onsubmit是 HTML <form>標簽的 HTML 屬性,它可以在服務器上以任何其他方式設置,即使用 OGNL,或者在客戶端使用 Z686155AF75A60A0F6E9D80C1F7EDDE3

此外,從 Struts1 遷移到 Struts 2 時,您應該閱讀Struts 1 到 Struts 2 遷移策略

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM