我有以下组合框:
<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”(字符串)。
我错过了什么?