0

Is it possible to configure Spring to set the target property to null when binding fails?

For example, my bean has a date property which can have a pre-existing value when the form is displayed. If the user enters an invalid date, I want the property to be set to null; currently it retains its previous value.

I still want the binding error of course, so I can display an error message.

I'm hoping there's a general configuration solution for this (ie. I don't want to just write code to deal with each field manually!).

Background: Retaining the old value causes odd behaviour in subsequent custom cross-field validation. Setting the property values to null would tell this validation not to execute.

4

0 回答 0