gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 05:56:36 24 4
gpt4 key购买 nike

有没有办法将 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com