Grails Domain has the function of automatic verification, but when I define the attribute of Domain, I define a field of the int type, and then use String when entering the field on the page, then he starts the automatic verification function and reports the following verification information.
Failed to convert property value of type [java. lang. String] to required type [int] for property
Age; nested exception is java. lang. IllegalArgumentException: cocould not parse number: Unparseable number: www.2cto.com
I just want to verify that the input Sting cannot be converted to the int type, and a message is displayed.
Then I plan to add Chinese to i18n for internationalization, but I found the English prompt in the source code, including in the path org. codehaus. groovy. grails. validation. * I searched all the packages below and did not find them. Later, I found that the API details the entered verification and a custom verification in 16 in i18n, this blog post-Grails study Note 2 is also available in the maai1024 blog. It is found that this configuration cannot be used for verification, and finally the messages in the i18n folder. in the properties configuration file
TypeMismatch. java. lang. Integer = Property {0} must be a valid number
As the name implies, the message prompt is returned when the type does not match. I will replace int with Integer, so that I can replace it with a Chinese prompt.