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

标签 grails grails-orm 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 

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

最佳答案

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

user.userName.nullable=Your custom text

关于grails - 在 Grails 中,我无法覆盖默认错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35883738/

相关文章:

grails - 验证 grails 域对象中的一组字段

database - Grails 一对一关系

grails - 为什么域类中字段的范围修饰符会阻止验证?

列表对象的 Grails 验证

grails - Grails:使用元标记传递属性

grails - Grails时间持续时间格式标记库

grails - grails从 Controller 返回xml字符串

grails - 依赖注入(inject)在使用邮件插件的 grails 作业中不起作用

grails - Grails:将自定义约束应用于Domain类的所有字段

grails - 如何知道验证错误的原因