在没有字段绑定的情况下使用表单错误?
我想知道您是否可以使用
我尝试创建像 Errors.reject("myError") 这样的全局错误,但是如何将其放入 jsp 中?我必须在命令对象中为此创建一个属性吗?
I am wondering whether you can use a <form:errors> tag to display an error that doesn't have a binding to a field in the command object. Basically I want to do some custom validation logic that isn't directly related to a single form element, but perhaps many or all, or none. What if I only wanted to validate forms from 9am to 3pm?
I tried creating a global error like Errors.reject("myError"), but then how do I put this in the jsp? Must I make an attribute just for this in the command object?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 Spring Errors,您可以选择将其用于:
要访问 JSP 中的全局错误,您可以使用不带
path
属性的
,或者可以直接访问错误变量:(@请参阅http://static.springsource.org/spring/ docs/1.2.x/taglib/tag/BindErrorsTag.html 查看变量列表)要仅在上午 9 点到下午 3 点之间启用验证,您需要实现自己的验证器。
With Spring Errors you have the choice to use it for:
To access global errors in the JSP, you could use
<form:errors />
withoutpath
attribute or you can access the error variable in a direct way: (@see http://static.springsource.org/spring/docs/1.2.x/taglib/tag/BindErrorsTag.html for a list of variables)To enable the validation only between 9am to 3pm you need to implement you own validator.