我有一个带有姓氏字段的 Person 对象。姓氏字段不能为空。当用户在 lastName 字段中提交表单空白值时,用户看到的错误消息是:
Property [lastName] of class [com.example.Person] cannot be blank
此错误消息很蹩脚。我想将其自定义为更用户友好的内容,例如“姓氏字段不能为空”
我怎么做?
我有一个带有姓氏字段的 Person 对象。姓氏字段不能为空。当用户在 lastName 字段中提交表单空白值时,用户看到的错误消息是:
Property [lastName] of class [com.example.Person] cannot be blank
此错误消息很蹩脚。我想将其自定义为更用户友好的内容,例如“姓氏字段不能为空”
我怎么做?
请参阅文档的第 7 章:http: //grails.org/doc/latest/
你会改变grails-app/i18n/messages.properties
并添加
person.lastName.blank=The Last Name field cannot be blank
在 Grails 3 中,您需要更改grails-app/i18n/messages.properties:
default.blank.message ={0} 字段不能为空