如何返回带有 ActionErrors 的多个表单的 JSP?
我有一个具有多种表单的 JSP 作为对象的“编辑”视图。现在我想发送其中一张表单,但 validate
方法中出现错误,因为其中一个输入字段未填写。
当验证 bean 并发现错误时,Struts 返回 JSP,该 JSP 在我的 struts-config.xml
中定义为 bean 的 INPUT。但现在其他形式都失去了它们的价值。
我怎样才能解决这个问题,以便我将返回到 JSP 并再次填写所有表单?
I have a JSP with multiple forms as the "edit" view of an object. Now I want to send one of the forms, but there is an error in the validate
method, because one of the input fields was not filled.
When the bean is validate and the error is found, Struts returns to the JSP which is defined as the INPUT for the bean in my struts-config.xml
. But now the other forms are missing their values.
How can I solve this issue, so I'll be returns to the JSP with all forms filled again?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当 Struts 从提交的表单接收参数时,它将它们绑定到 ActionForm 对象,然后在 ActionForm 对象上调用 validate()。当您返回页面时,绑定的参数仍保留在那里,并且您的值应该出现在页面中。
有一些事情可能会干扰此机制:
复选框-从你的问题来看,它
似乎不太可能是这样;
When Struts receives the parameters from your submitted form, it binds them to the ActionForm object and then calls validate() on the ActionForm object. The binded parameters remain there when you return to the page and you should have your values present in the page.
There are some things that can interfere with this mechanism:
checkboxes - from your question, it
seems unlikely to be this;