[英]How can I make a Grails domain class show the name field?
I am using a class to populate a list and but the drop-down list on my view shows the fully qualified name of the class only: 我正在使用一个类来填充列表,但是视图上的下拉列表仅显示该类的完全限定名称:
com.pomodoro.Product : 2
com.test.Product : 1
Add this to the bottom of your class: 将其添加到班级底部:
String toString() { return name }
You need to override the toString()
class method 您需要重写toString()
类方法
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.