如何使用playframework模板系统访问地图(groovy) [英] How to access a Map using playframework template system (groovy)
本文介绍了如何使用playframework模板系统访问地图(groovy)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在使用 - 非常出色的playframework,并且无法找到关于如何使用play的模板引擎从视图访问Map数据结构的文档/示例。
更具体地说,我希望在迭代对象列表时访问Map,例如,
#{list items:itemList,as:'item'}
//使用$ {item?.id}作为键$ b $访问地图值b#{/ list}
感谢您的关注。
render(map,itemList)=h2_lin>解决方案
); // map是一个Map
这个应该工作:
#{list items:itemList,as:'item'}
//使用$ {item? id}作为关键字
$ {map.get(item.?id)}
#{/ list}
I've been using the--quite excellent--playframework and have had trouble finding documentation/examples on how to access a Map data structure from a view, using play's template engine.
To be even more specific, I wish to access the Map as I iterate over a List of objects, e.g.,
#{list items:itemList, as:'item'}
// access the map value using the ${item?.id} as the key
#{/list}
Thank's for looking.
解决方案
Assuming you do in the Controller:
render(map, itemList); //map is a Map
This should work:
#{list items:itemList, as:'item'}
// access the map value using the ${item?.id} as the key
${map.get(item.?id)}
#{/list}
这篇关于如何使用playframework模板系统访问地图(groovy)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文