轉(zhuǎn)載自:http://www.513school.com/bbs/admin/1/111448.html
現(xiàn)項(xiàng)目使用beetl模板生成代碼浸遗,用到了for循環(huán)
網(wǎng)上查找到資料是這樣的
<select>
? ? @for(item in list){
? ? ? ? <option value="${item.id}">${item}</option>
? ? @}
</select>
由于我是使用xx.btl文件生成的拣度,所以以上方式并不適用
原來(lái)要使用以前類似于jsp寫java代碼的方式挣轨,使用<%? %> 將代碼包括起來(lái)
一下是我的例子
<% for(item in columnList ){ %>
? ? ? ? ?<%if(item.type != '' && item.type == 'select'){%>
? ? ? ? ?{
? ? ? ? ? ? label: '${item.name}',
? ? ? ? ? ? prop: '${item.code}',
? ? ? ? ? ? type: TableColumnOrFormTypeEnum.SELECT,
? ? ? ? ? ? dicCode: '${item.enumtype}',
? ? ? ? ? ? placeholder: '請(qǐng)選擇${item.name}',
? ? ? ? ? },
? ? ? ? ?<%}else if(item.type != '' && item.type == 'date'){%>
? ? ? ? ?{
? ? ? ? ? ? label: '${item.name}',
? ? ? ? ? ? prop: '${item.code}',
? ? ? ? ? ? type: TableColumnOrFormTypeEnum.DATE,
? ? ? ? ? ? placeholder: '請(qǐng)選擇${item.name}',
? ? ? ? ? },
? ? ? ? ?<%}else if(item.type != '' && item.type == 'moneyinput'){%>
? ? ? ? ?{
? ? ? ? ? ? label: '${item.name}',
? ? ? ? ? ? prop: '${item.code}',
? ? ? ? ? ? type: TableColumnOrFormTypeEnum.MONEYINPUT,
? ? ? ? ? },
? ? ? ? ?<%}else if(item.type != '' && item.type == 'textarea'){%>
? ? ? ? ?{
? ? ? ? ? ? label: '${item.name}',
? ? ? ? ? ? prop: '${item.code}',
? ? ? ? ? ? type: TableColumnOrFormTypeEnum.TEXTAREA,
? ? ? ? ? ? placeholder: '請(qǐng)輸入${item.name}',
? ? ? ? ? ? maxlength: 200,
? ? ? ? ? ? expand: ${item.expand},
? ? ? ? ? },
? ? ? ? ?<%}else{%>
? ? ? ? ? {
? ? ? ? ? ? label: '${item.name}',
? ? ? ? ? ? prop: '${item.code}',
? ? ? ? ? ? type: TableColumnOrFormTypeEnum.INPUT,
? ? ? ? ? },
? ? ? ? ? ? <%}%>
? ? ? ? <%}%>
特此記錄下來(lái)过牙,以供大家學(xué)習(xí)分享