I18n automatically verified by Grails Domain

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.