freemarker模板select读取数据库状态回显

<select name="parentId" class="selector">
     <option value="0">请选择菜单</option>
     <#if pMenu?exists>
        <#list pMenu as model>
           <option value="${model.id?if_exists}" <#if menu.parentId== model.id>selected</#if>>${model.name}</option>
        </#list>
     </#if>
</select>
<#if pMenu?exists> --判断列表pMenu是否为空
<#list pMenu as model> --遍历列表
${model.id?if_exists} --判断pMenu的行内数据id是否为空
<#if menu.parentId== model.id> --判断数据库传来的parentId与pMenu的列表的id是否相等,如字段是String在数据库传来的数据后加入?string即可


效果展示

 

 

 

 

posted @ 2018-10-25 10:28  H2SO3  阅读(3720)  评论(0编辑  收藏  举报