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即可


效果展示

 

 

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM