java - Exception while binidng form to bean using Spring MVC, JSR 303 Annotation -
I have the following spring form: Input tag in my JSP which accepts on date.
& lt; Look: input type = "text" id = "fromDate" path = "fromDate" /> And I have a corresponding Java bean to force the date of the user to date by the user of the bean property. Private date from date of
@NotNull @Past @DateTimeFormat (Pattern = "MM / DD / Yay"); When those "mm / dd / yyyy" format enters the date in the format I am not getting any exception and the value is being set to the bean variable properly.
The user enters the date in another format when (former: 23/12/2012) or an invalid date (ex: 060412009324092014). I'm having the following exception
type Java property failed to change the value of the expected type for java.util.Date from date. Property to lang.Date; The nested exception is org.springframework.core.convert.ConversionFailedException: Type to convert to java.lang.String from @javax.validation.constraints.NotNull @javax.validation.constraints.past @ org.springframework.format .annotation failed Date format for date 060412009324092014; java.util.Date; The nested exception is java.lang.IllegalArgumentException:. Unable to parse 060412009324092014
Please help to display a valid message instead of an exception on the page
thanks Mike
I was able to solve the problem by having the following property. Was
typeMismatch.bean.fromDate = From the invalid date!
Thanks Mark.
Comments
Post a Comment