[英]While migrating Struts 1 to Struts 2, the FormTag class in Struts 2 is missing a getOnsubmit method
I am doing a Struts 1 to Struts 2 migration.我正在执行 Struts 1 到 Struts 2 的迁移。 We have Struts 1 code that has extended and customised the org.apache.struts.taglib.html.FormTag
.我们有 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. Did some search and found that the org.apache.struts2.views.jsp.ui.FormTag
is the equivalent in Struts2.
My current Struts 1 code modifies the onsubmit
variable of the FormTag
by calling the setOnsubmit()
, but it does that by first doing a getOnsubmit()
like below.我当前的 Struts 1 代码通过调用setOnsubmit()
来修改FormTag
的onsubmit
变量,但它通过首先执行如下所示的getOnsubmit()
来实现。
if (this.getOnsubmit() == null) {
this.setOnsubmit(subCmd + subCmdEnd);
}
else {
this.setOnsubmit(subCmd + this.getOnsubmit() + subCmdEnd);
}
The Struts 2 class has the setOnsubmit()
, but not the getOnsubmit()
. Struts 2 class 有setOnsubmit()
,但没有getOnsubmit()
。 Do we have any other option available to read the onsubmit
value?我们还有其他选项可以读取onsubmit
值吗?
The <s:form>
tag belongs to Struts 2 core tag library.<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. 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. The onsubmit
field has a protected
modifyer. onsubmit
字段有一个protected
的修饰符。
But before doing any changes to the Struts 2 framework ask an advice from qualifyed experts: why do you need to do it?但在对 Struts 2 框架进行任何更改之前,请咨询合格专家的建议:为什么需要这样做? For carrying the old code to the new one?为了将旧代码带到新代码? The code that is written for S1 is incompatible with S2.为 S1 编写的代码与 S2 不兼容。
onsubmit
is a HTML attribute of the HTML <form>
tag, and it could be set in the any other ways on the server, ie using OGNL, or on the client using JavaScript. onsubmit
是 HTML <form>
标签的 HTML 属性,它可以在服务器上以任何其他方式设置,即使用 OGNL,或者在客户端使用 Z686155AF75A60A0F6E9D80C1F7EDDE3
Also when migrating from Struts1 to Struts 2 you should read Struts 1 to Struts 2 migration strategy .此外,从 Struts1 迁移到 Struts 2 时,您应该阅读Struts 1 到 Struts 2 迁移策略。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.