【发布时间】:2016-03-03 18:58:47
【问题描述】:
我正在尝试使用一个模板动态创建多个 div,该模板被调用了多次,每次我创建一个新的 div 时...下面的代码似乎工作正常。我将地图 tempMap 从控制器传递到以下格式的 gsp 页面
tempMap = [key_1:v1,key_2:v2,key_3:v3] //from the controller
//this is the gsp part
<g:set var="counter" value="${1}" />
<g:while test="${counter <= tempMap.counter}">
<g:render template="travelDetailsToShow" />
<g:set var="counter" value="${counter + 1}" />
</g:while>
我需要根据也可以工作的计数器设置元素的 ID ...但我无法设置字段的值。
<div class="col-sm-6" id="key_${counter}"> // This sets the id to key_1, key_2 depending on the counter value
<div class="form-group">
<label>Departure Date</label>
<span class="input-icon-right input-group">
<g:set var="temp" value="kep_${counter}" />
**<input type="text" name="key_${counter}" class="form-control" value="${tempMap?.key_${counter}}" readonly></input> // this does not work**
<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
</span>
</div>
</div>
我搜索了很多,但没有运气......谁能告诉我我哪里出了问题......感谢任何帮助......在此先感谢人们
【问题讨论】: