【问题标题】:grails 2.3.3 command validation error messagesgrails 2.3.3 命令验证错误消息
【发布时间】:2013-12-17 15:05:15
【问题描述】:

我们最近从 2.2.3 升级到 2.3.3,现在无法从 messages.properties 中获取命令验证失败的错误消息。

如此处所述:http://grails.org/doc/latest/guide/validation.html 我将错误代码更新为末尾没有 .error。

这是我的命令:

@Validateable
class GroupCommand {
  String name


  static constraints = {
    name blank: false, unique: true
  }

这是 grails-app/i18n/messages.properties 中的条目:

groupCommand.name.blank=Please enter a name for that group

这是验证失败时我收到的错误消息:

Property [name] of class [class au.edu.rmit.its.iim.googlegrey.GroupCommand] cannot be null

我尝试添加完整的包描述,添加 .error,以及所有组合,并且此消息未被验证接收。

我可以使用消息标签获取它们,但验证系统找不到它们。

有没有人为此找到解决方法,还是我做错了什么?

【问题讨论】:

  • 您是否尝试过注释掉在messages.properties 中为blank 约束提供的默认消息?

标签: validation grails


【解决方案1】:

2.3 中的新数据绑定器将空白转换为 null - 请参阅 http://grails.org/doc/2.3.0/guide/introduction.html#whatsNew23

你可以这样配置:

grails.databinding.convertEmptyStringsToNull = false

详情请见http://grails.org/doc/2.3.0/guide/single.html#dataBinding

【讨论】:

  • 有道理,谢谢,我想知道为什么它是空而不是空白,但没有连接点。
猜你喜欢
  • 1970-01-01
  • 2013-06-06
  • 1970-01-01
  • 2011-06-07
  • 1970-01-01
  • 1970-01-01
  • 2014-09-04
  • 2017-03-22
  • 2018-12-10
相关资源
最近更新 更多