我有以下组合框:

<g:select name="ticketType" from="${app.domain.enums.TicketType?.values()}"
                              keys="${app.domain.enums.TicketType.values() }"
                              value="${ticketInstance?.ticketType}"
                              noSelection="${['null': 'Select One...']}"
                    />

我在命令对象中为ticketType设置了以下约束
ticketType nullable: true, blank:true

TicketType是一个非常简单的枚举:
    public enum TicketType {
        QUESTION, SUPPORT, MAINTENANCE, NEW_FUNCTIONALITY, MALFUNCTION
}

每次我在GSP中未为ticketType设置一些值时,都会出现以下错误:
Failed to convert property value of type 'java.lang.String' to required type 'com.coming.enums.TicketPriority'

就像在没有选择的情况下,g:select设置“null”(字符串)的值。

我想念什么?

最佳答案

您是否尝试过使用空字符串作为noSelection属性,而不是使用“null”字面量?例如noSelection="${['':'Select One...']}"?在数据绑定(bind)期间,这可以将其正确转换为真正的null值。

10-06 01:18