Grails3中的g:select没有检索数据

Grails3中的g:select没有检索数据,grails,groovy,Grails,Groovy,Grails3中的g:select没有检索数据。 我的代码如下- <g:select from="${Machine_summaryList}" name="brand" /> 这里“Machine\u summaryList”是“Machine\u summary”类的列表,“brand”是我需要检索的数据列。在这种情况下,您需要使用optionValue=“brand” 您的g:select必须如下所示: <g:select from="${Machine_summa

Grails3中的g:select没有检索数据。 我的代码如下-

<g:select from="${Machine_summaryList}" name="brand" />


这里“Machine\u summaryList”是“Machine\u summary”类的列表,“brand”是我需要检索的数据列。

在这种情况下,您需要使用
optionValue=“brand”

您的
g:select
必须如下所示:

<g:select from="${Machine_summaryList}" name="brand" optionKey="id" optionValue="brand"/>


当表单提交时,您将在
params.brand

中收到所选机器,仅此过程适用于我

<g:select from="${project.Machine_summary.executeQuery("select distinct c.brand from Machine_summary c")}" name="brand" />


问题是?这里所有的品牌名称都应该输入select,但数据不可检索。您怎么知道?mayby您的列表为空?我的列表中有数据。请尝试根据添加
optionKey
value
属性。我也使用了此属性,但它不起作用,而我在Machine\u summaryList中有数据,它使用“${Machine\u summaryList}”将数据抛出list.gsp,但在g:select上不起作用