有没有办法将 Grails 转换不匹配错误更改为自定义消息?
我得到:
Failed to convert property value of type
java.lang.String
to required typejava.util.Map
for propertyitems
;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/