问题描述
我有 BindingResult结果
,其字段日期 FieldError
/ code>。如何删除此错误?
I have a BindingResult result
that has a FieldError
registered for the field date
. How can I remove this error?
假设错误已添加为 result.rejectValue(date,my_code,my_message) ;
提前致谢
推荐答案
嗯,首先,BindingResult是一个接口,而不是具体的类,并且接口没有指定任何方法来删除错误。
Well, first of all, BindingResult is an interface, not a concrete class, and the interface doesn't specify any way to remove an error.
取决于哪个实现在您正在处理的接口中,可能有一个方法(超出BindingResult接口中指定的方法)来执行此操作,但似乎不太可能。
Depending on which implementation of the interface you are dealing with, there may be a method (beyond what's specified in the BindingResult interface) to do this, but it seems unlikely.
我能想到的唯一一件事就是创建一个新的BindingResult实例,然后遍历错误并重新创建除了你要忽略的那个之外的所有错误。新的。
The only thing that I can think of is to create a new BindingResult instance, then loop through the errors and re-create all but the one that you want to ignore in the new one.
这篇关于Spring - 如何从BindingResult中删除`FieldError`?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!