如何让 Grails 域 class 显示名称字段?

How can I make a Grails domain class show the name field?

我正在使用 class 填充列表,但我视图中的下拉列表仅显示 class 的完全限定名称:

com.pomodoro.Product : 2
com.test.Product : 1

将此添加到 class 的底部:

String toString() { return name }

您需要覆盖 toString() class 方法