[英]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()
來修改FormTag
的onsubmit
變量,但它通過首先執行如下所示的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.