grails/gorm 消息包

发布于 2024-10-08 11:06:11 字数 763 浏览 1 评论 0原文

请帮我解决这件事。这次我会更具体,因为我已经得到了一个答案,并且无法让它发挥作用。我有一堂课:

package aa1

class City {

    String name

    static constraints = {
        name(blank: false, nullable:false, unique: true, matches:"[a-zA-z ]+")
    }

    String toString(){
        name
    }
}

我想为此制作一个定制的错误消息。为此,我在 messages.proprietis 中添加了(因为我不知道约束语法的类型是什么):

aa1.City.name.doesnt.match=Letters between a-z and spaces.
aa1.City.name.match=Letters between a-z and spaces.
aa1.City.name.matches=Letters between a-z and spaces.

我得到的错误消息是:

Property [username] of class [class trafficmanfinal.User] with value ["] does not match the required pattern [[a-zA-z0-9]+]

我无法让它工作。请告诉我是否有任何自定义错误语法列表可以在网络上为我提供帮助。

Please help me with this thing. I'll be more specific this time, because i have already got an ansfor for this and cudnt get this to work. I have a class:

package aa1

class City {

    String name

    static constraints = {
        name(blank: false, nullable:false, unique: true, matches:"[a-zA-z ]+")
    }

    String toString(){
        name
    }
}

I want to make a customized error message for this. For that, i added in the messages.proprietis (because i didnt know what was the type of constraint syntax):

aa1.City.name.doesnt.match=Letters between a-z and spaces.
aa1.City.name.match=Letters between a-z and spaces.
aa1.City.name.matches=Letters between a-z and spaces.

All i get for the error message is:

Property [username] of class [class trafficmanfinal.User] with value ["] does not match the required pattern [[a-zA-z0-9]+]

I can't get this to work. And let me know if there is any list of customized error syntax to help me in the web.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

偏爱你一生 2024-10-15 11:06:11

尝试

aa1.City.name.matches.invalid=the message

try

aa1.City.name.matches.invalid=the message
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文