从映射到html选择框的groovy解析值

时间:2014-06-10 04:52:10

标签: grails

我有一张这样的地图

company = [no:[01, 02], name:[abc, def]]

如何在html上的选择框中显示这些信息?这意味着每个选项都有值:

option1: 01: abc
option2: 02: def

我试过

<select>
   <g:each in="${grailsApplication.config.Companies}" var="company">
      <option>${company}</option>
   </g:each>
</select>

但它只显示 选项1:否:[01,02] 选项2:名称:[abc,def]] 请帮忙,谢谢!

注意:$ {grailsApplication.config.Companies} =上面的阵列公司

1 个答案:

答案 0 :(得分:2)

尝试像这样实现它

<select>
   <g:each in="${grailsApplication.config.Companies[no]}" var="company" status="index">
     <option value="${grailsApplication.config.Companies['no'][index]}">${grailsApplication.config.Companies['name'][index]}</option>
   </g:each>
</select>