客户端的Javascript可以访问Struts表单吗?
在 Struts 中,我们在 struts-config.xml
中定义了一些名为 TaskForm
的表单。
在其中一个 JavaScript 函数中,我可以看到这样的语句:
document.TaskForm(some form name in struts-config.xml).action = action
我的问题是我们如何能够在客户端执行 document.taskform
?
我的意思是像 document.getElementByid("")
这样的语句是在浏览器端定义的,但不确定 document.taskform
吗?
In Struts say we define some form with the name TaskForm
in struts-config.xml
.
In one of the javascript function, I can see the statement:
document.TaskForm(some form name in struts-config.xml).action = action
My question here is how come we are able to execute document.taskform
at client side?
I mean statements like document.getElementByid("")
are defined in browser side but not sure about document.taskform
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法使用 JavaScript 访问 Struts ActionForms!
您所看到的是 JavaScript 与 HTML 客户端
HTML
ActionForm
是客户端 HTMLHTML
保留一些名称和值是为了保持代码的清晰度。这使得事情变得同质。但我们说的不是同一件事!
You can't access Struts ActionForms using JavaScript!
What you are seeing is JavaScript interaction with the HTML client side
<form>
tag (something like this tutorial presents)The HTML
<form>
tag happens to have the same attributename
andaction
value as the ones from the<form-bean>
and<action>
tags ofstruts-config.xml
.This is no coincidence!
ActionForm
s are the server side object representation of a client side HTML<form>
tag and Struts server tags generate HTML which is then sent to the client.The HTML
<form>
tag usually contains the name of the bean specified in<form-bean>
ofstruts-config.xml
tag, while theaction
attribute of the<form>
is the one specified in the corresponding<action>
ofstruts-config.xml
.Some names and values are preserved to maintain clarity of the code. This makes things homogeneous. But we are NOT talking about the same thing!