Is there a way to use a title instead of a variable name when overriding Spring’s default messages using the messages.properties file?
For example, I used this
typeMismatch.java.lang.Integer={0} must be a number.
to create the error message “firstName must be a number.”, but I would prefer more readability, like “First Name must be a number.”.
Is there any way to do this?
You can customize the property for a specific field of a specific class. Say your model attribute is named foo and it has a property named firstName then you can declare a custom error message for that specific field using:
You can see this page for more information.