我有一张如下地图:
final static def BANK_NAMES = [
bofa:[fullname:'Bank of America',hasPin:false],
chase:[fullname:'Chase Bank',hasPin:false],
wells:[fullname:'Wells Fargo Bank',hasPin:false],
citi:[fullname:'Citibank',hasPin:false],
us:[fullname:'US Bank',hasPin:false],
usaa:[fullname:'USAA',hasPin:false],
charles:[fullname:'Charles Schwab',hasPin:false]
]
我试图像这样显示价值:
<g:each in="${BankConstants.BANK_NAMES}" var="banks">
<option id="status">${banks}</option>
</g:each>
它显示如下:
bofa={fullname=Bank of America, hasPin=false}
有没有办法显示&#34; fullname&#34;的价值?在一个或标签。有人可以帮忙吗?
答案 0 :(得分:3)
您可以尝试:
<g:each in="${BankConstants.BANK_NAMES}" var="banks">
<option id="status">${banks.value.fullname}</option>
</g:each>
答案 1 :(得分:1)
您可以更改
final static def BANK_NAMES = [
[id: 'bofa', fullname:'Bank of America',hasPin:false],
[id: 'chase', fullname:'Chase Bank',hasPin:false],
[id: 'wells', fullname:'Wells Fargo Bank',hasPin:false],
[id: 'citi', fullname:'Citibank',hasPin:false],
[id: 'us', fullname:'US Bank',hasPin:false],
[id: 'usaa', fullname:'USAA',hasPin:false],
[id: 'charles', fullname:'Charles Schwab',hasPin:false]
]
所以你将拥有地图列表。然后您可以通过以下方式访问全名:
${banks.fullname}
修改强> 您也可以尝试:
<g:each in="${BankConstants.BANK_NAMES.value}" var="banks">
<option id="status">${banks.fullname}</option>
</g:each>
但我不确定这是否有用。