Grails3中的下拉列表

Grails3中的下拉列表,grails,grails-3.3,Grails,Grails 3.3,我正在使用grails3.3.10开发一个应用程序,我试图创建一个下拉列表,但我将其设为空,我正在将值放入application.yml文件中,下面是我的代码 application.yml: profile: accType: ['supplier', 'buyer', 'both'] 域: class Profile { String accType static constraints = { accType(nullable: true, InList: Holders.conf

我正在使用
grails3.3.10
开发一个应用程序,我试图创建一个下拉列表,但我将其设为空,我正在将值放入
application.yml
文件中,下面是我的代码

application.yml:

profile:
   accType: ['supplier', 'buyer', 'both']
域:

class Profile {
String accType
static constraints = {
accType(nullable: true, InList: Holders.config.getProperty('profile.accType'))
  }

} 
_表1.gsp

<g:select required="" style="width:auto;" class="form-control input" name="accType" from="${Profile.constrainedProperties.accType.inList}" value="${profileInstance?.accType}" valueMessagePrefix="profile.accType"/>

您有:

static constraints = {
    accType(nullable: true, InList: Holders.config.getProperty('profile.accType'))
}
你可能想要这个:

static constraints = {
    accType(nullable: true, inList: Holders.config.getProperty('profile.accType', List))
}
请注意,
InList
应该是
InList
,开头有一个小写的
“i”
,您希望将两个参数传递给
getProperty
,第二个参数是
列表
类文字。

您有:

static constraints = {
    accType(nullable: true, InList: Holders.config.getProperty('profile.accType'))
}
你可能想要这个:

static constraints = {
    accType(nullable: true, inList: Holders.config.getProperty('profile.accType', List))
}

请注意,
InList
应该是
InList
,开头带有小写的
“i”
,您希望将两个参数传递给
getProperty
,第二个参数是
列表
类文本。

我按照您提到的做了,但仍然将其变为空,任何其他建议它对我都有效。我把代码放在了项目中。下拉列表位于(请注意,我刚刚在表单中删除了下拉列表,以验证它是否已填充,您可能希望进行调整),并且在处指定了约束。所有这些看起来都是可行的。如果您可以共享一个演示问题的项目,那么解决问题就很简单了。我在那里链接的示例应用程序花了2到3分钟创建。感谢您的努力,这里是Github上项目的快照,下拉列表仍然为空!!!问题就在这里。如果您将
InList
更改为
InList
,则您的下拉列表将正常工作,因为
InList
约束将正确初始化。我已按您所述进行了初始化,但仍然为空,任何其他建议对我都有效。我把代码放在了项目中。下拉列表位于(请注意,我刚刚在表单中删除了下拉列表,以验证它是否已填充,您可能希望进行调整),并且在处指定了约束。所有这些看起来都是可行的。如果您可以共享一个演示问题的项目,那么解决问题就很简单了。我在那里链接的示例应用程序花了2到3分钟创建。感谢您的努力,这里是Github上项目的快照,下拉列表仍然为空!!!问题就在这里。如果将
InList
更改为
InList
,则下拉列表将正常工作,因为
InList
约束将正确初始化。