For those who do not understand this idea, here is what to do in spring 4.2.0 . Create the file name messages.properties in the WEB-INF > classes folder. And put the above type mismatch messages in this file. In the spring or servlet.xml create the following bean.
<beans:bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> <beans:property name="basename" value="messages"></beans:property> </beans:bean>
And for your model attribute, such as private Integer aNumber; in question, along with other validation rules, this rule is also used to convert type mismatches. In this case, you will receive your message.
<form:errors path="aNumber"></form:errors>
Hope this helps others.
Zahid khan
source share