如何在grails中动态选择县-州-市

如何在grails中动态选择县-州-市,grails,gsp,Grails,Gsp,我正在尝试使用域类从我的数据库中获取国家、州和城市。但我需要更简单的方法来取。有没有办法通过使用Grails标记来获取这些信息 <g:countrySelect/> <div class="form-group"> <div class="col-lg-2"></div> <div class="fieldcontain ${hasErrors(bean: accountInstance, field: 'country',

我正在尝试使用域类从我的数据库中获取
国家
城市
。但我需要更简单的方法来取。有没有办法通过使用Grails标记来获取这些信息

<g:countrySelect/>

<div class="form-group">
    <div class="col-lg-2"></div>
    <div class="fieldcontain ${hasErrors(bean: accountInstance, field: 'country', 'error')} ">
        <label class="col-lg-3 control-label" for="country">
        <g:message code="account.country.label" default="Country" />
        </label>

        <g:select id="country" name="country.id" from="${org.preva.Country.list()}"
                  optionKey="id" value="${accountInstance?.country?.id}"
                  class="many-to-one" noSelection="['null': 'Choose Country']"
                  style="width:160px"/>
    </div>
</div>

<div class="form-group">
    <div class="col-lg-2"></div>
    <div class="fieldcontain ${hasErrors(bean: accountInstance, field: 'state', 'error')} ">
        <label class="col-lg-3 control-label" for="state">
        <g:message code="account.state.label" default="State" />
        </label>
        <g:select id="state" name="state.id" from="${org.preva.State.list()}"
                  optionKey="id" value="${accountInstance?.state?.id}"
                  class="many-to-one" noSelection="['null': 'Choose State']"
                  style="width:160px"/>
    </div>
</div>

<div class="form-group">
    <div class="col-lg-2"></div>
    <div class="fieldcontain ${hasErrors(bean: accountInstance, field: 'city', 'error')} ">
        <label class="col-lg-3 control-label" for="city">
        <g:message code="account.city.label" default="City" />
        </label>
        <g:select id="city" name="city.id" from="${org.preva.City.list()}"
                  optionKey="id" value="${accountInstance?.city?.id}"
                  class="many-to-one" noSelection="['null': 'Choose City']"
                  style="width:160px"/>
    </div>
</div>


是否有默认标记?

您的意思是您正在寻找比当前
org.preva.City.list()更简单的标记。
?我真的不理解grails中当前关于国家选择的问题。因此,我问的州和城市是否有预定义的标记。因此,您当前使用的问题是
value=“${org.preva.city.list()}”
,但希望
value=“${city}”
取而代之的是,看看AjaxDependencySelection/Boseleta插件