【问题标题】:In Grails, I cannot override the default error message在 Grails 中,我无法覆盖默认错误消息
【发布时间】:2016-06-23 08:44:32
【问题描述】:
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

【问题讨论】:

  • 我也在静态约束中尝试了 userName blank:false ......但结果相同
  • 我相信应该是User.userName.nullable=The User Name cannot be null/blank
  • 谢谢。它正在工作。应该是 user.userName.nullable=用户名不能为空/空。
  • 酷。那么也许你应该为你自己的问题提供一个答案:)

标签: grails grails-orm grails-validation


【解决方案1】:

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

user.userName.nullable=Your custom text

【讨论】:

    猜你喜欢
    • 2011-06-22
    • 1970-01-01
    • 2011-02-25
    • 2010-12-01
    • 2019-03-20
    • 1970-01-01
    • 2023-03-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多