版权声明:本文为博主原创文章,未经博主允许不得转载。
【需求】
遍历一个list,同时需要在每个item前面显示字母序号,例如A,B,C,D
【代码】
- #set($zimu = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"])
- #set($k=0)
- #foreach($item in ${questionDTO.answerList})
- <span class="exe_mc_option" data-obid="${item.obid}">
- <span class="optionid">$zimu.get($k)</span>${item.answerContext}
- </span>
- #set($k=$k+1)
- #end
【说明】
这里定义了一个k,如果使用$zimu.get($velocityCount-1)这种形式会报错,没有深究原因。