在Grails中,我无法覆盖默认的错误消息

时间:2016-03-09 05:36:52

标签: grails gorm grails-validation

class User {
     String userName
     static constraints = {
        userName nullable:false
     }
}

*** I tried the different combination of the following in the message.properties ***
User.userName.null.message=The User Name cannot be null/blank
User.userName.null=The User Name cannot be null/blank
[package].User.userName.null.message=The User Name cannot be null/blank 
[package].User.userName.null=The User Name cannot be null/blank 

但仍然没有运气。我仍然收到默认错误消息,即" clas [package_name]的属性[userName]不能为空。我使用的是Grails 3.0.8

1 个答案:

答案 0 :(得分:1)

关键是user.userName.nullable。在资源包中使用以下条目。

user.userName.nullable=Your custom text