Is there a way to change Grails conversion mismatch error to custom message?
I am getting:
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
This error type is not in messages.properties
. I am getting this if a user tries to inject request parameter which is not a map into my Command Object, they shouldn't be doing this, but that besides the point:
class CartCommand implements Serializable {
Map<Integer, Integer> items =
MapUtils.lazyMap([:], FactoryUtils.constantFactory(''))
}
Thanks
Use the following key in your message.properties
:
cartCommand.items.typeMismatch.map
精彩评论