【问题标题】:Changing grails "no conversion strategy" error that is not in message.properties更改不在 message.properties 中的 grails“无转换策略”错误
【发布时间】:2011-09-23 03:25:08
【问题描述】:

有没有办法将 Grails 转换不匹配错误更改为自定义消息?

我得到:

无法将 java.lang.String 类型的属性值转换为必需 为属性items 键入java.util.Map;嵌套异常是 java.lang.IllegalStateException:无法转换类型的值 [java.lang.String] 到所需类型 [java.util.Map] 的属性 项目:未找到匹配的编辑器或转换策略

此错误类型不在messages.properties 中。如果用户尝试将不是映射的请求参数注入到我的命令对象中,我会得到这个,他们不应该这样做,但除此之外:

class CartCommand implements Serializable {
  Map<Integer, Integer> items = 
                MapUtils.lazyMap([:], FactoryUtils.constantFactory(''))
}

谢谢

【问题讨论】:

    标签: grails


    【解决方案1】:

    在您的message.properties 中使用以下密钥:

    cartCommand.items.typeMismatch.map
    

    【讨论】:

      猜你喜欢
      • 2014-07-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-26
      • 2017-02-12
      相关资源
      最近更新 更多