grails - 更改不在 message.properties 中的 grails "no conversion strategy"错误

标签 grails

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

我得到:

Failed to convert property value of type java.lang.String to required type java.util.Map for property items;nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [java.util.Map] for property items: no matching editors or conversion strategy found

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

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

谢谢

最佳答案

message.properties 中使用以下键:

cartCommand.items.typeMismatch.map

关于grails - 更改不在 message.properties 中的 grails "no conversion strategy"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7523908/

相关文章:

intellij-idea - @Grab 不能在用于 groovy 的 intellij IDE 中工作

hibernate - 在集成测试期间,Grails hibernate 事件未触发

grails - 使用Spring Security在Grails中拦截通配符URL

grails - Gant脚本缓存导致问题

grails - Grails GSP渲染问题

grails - 如何在grails中使用事件推送插件

Grails REST CRUD Controller 方法

grails - Grails插件不能依赖其他Grails插件吗?

testing - 为非 GORM 对象构建 Grails 测试数据

hibernate - Grails事务问题IllegalStateException key BasicDataSource TransactionSynchronizationManager.bindResource的已有值