开发者

Changing grails "no conversion strategy" error that is not in message.properties

开发者 https://www.devze.com 2023-04-06 17:00 出处:网络
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

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 开发者_运维技巧 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

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
0

精彩评论

暂无评论...
验证码 换一张
取 消