在 struts 2.0.14 中,组件提交页面后按钮不起作用?
我的应用程序使用 Struts2.0.14。我有一个按钮可以清除文本框。我有一些有状态的框,并且在提交表单后值是持久的。
我的问题是,当我在提交表单之前按下按钮时,它会清除文本框中的所有值。但是,当我提交表单并再次按重置时,文本框不会重置。
I am using Struts2.0.14 for my application. I have a button to clear the textboxes. I have a few boxes which are stateful and values are persistent after the form is submitted.
My problem is that when I press the button before submitting the form it clears all values from the textboxes. But when I submit the form and press reset again, the textboxes do not reset.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定这是否是您的问题,但是:“重置”HTML 表单的字段与“清除”它们不同,它只是意味着将它们的值重置为“默认”值,即那些(通常)在字段标记的
value="..."
属性中设置。现在,考虑典型的服务器端表单验证工作流程,当用户输入一些字段值、提交表单,并从服务器返回并标记一些错误时(通常在 Struts2 中,这对应于
INPUT< /代码>结果)。在这里,返回给用户的新 HTML 页面的表单字段将填充之前提交的值。现在,从客户端的角度来看,这些是表单的“默认”值:如果您“重置”表单(可能在编辑它之后),这些是将恢复的值。
I'm not sure if this is your problem, but: to "reset" the fields of an HTML form is not the same as to "clear" them, it just means to reset their values to their "default" values, those that were set (typically) in the
value="..."
attribute of the field tag.Now, consider the typical server-side form validation workflow, when the user has entered some field values, submited the form, and get it back from the server with some errors marked (typically in Struts2, this corresponds to the
INPUT
result). Here, the new HTML page that is returned to the user will have its form fields filled with the previously submitted values. Now, from the client side perspective, those are the "default" values of the form: if you "reset" the form (perhaps after editing it), those are the values that will be restored.