freemarker写select组件

1、宏定义

  1. <#macro select id datas value="" key="" text="" headKey="" headValue="">
  2. <select id="${id}" name="${id}">
  3. <option>---请选择---</option>
  4. <#if headKey!="">
  5. <option value="${headKey}">${headValue}</option>
  6. </#if>
  7. <#list datas as data>
  8. <#if key!="">
  9. <#if value == data[key]?string>
  10. <option value="${data[key]}" selected>${data[text]}</option>
  11. <#else>
  12. <option value="${data[key]}">${data[text]}</option>
  13. </#if>
  14. <#else>
  15. <#if value == data>
  16. <option value="${data}" selected>${data}</option>
  17. <#else>
  18. <option value="${data}">${data}</option>
  19. </#if>
  20. </#if>
  21. </#list>
  22. </select>
  23. </#macro>

2、引入宏

  1. <@items.select id="username" datas=users key="userNo" text="userName" headKey="0" headValue="其他"/>

3、示例结果

  1. <select id="username" name="username">
  2. <option>---请选择---</option>
  3. <option value="0">其他</option>
  4. <option value="1">张三丰</option>
  5. <option value="2">李思思</option>
  6. <option value="3">赵武</option>
  7. <option value="4">刘雪</option>
  8. <option value="5">朱顾</option>
  9. <option value="6">赵武</option>
  10. <option value="7">吴语</option>
  11. <option value="8">血玉</option>
  12. </select>

freemarker写select组件(四)的更多相关文章

  1. freemarker写select组件(一)

    freemarker写select组件 1.宏定义 <#macro select id datas> <select id="${id}" name=" ...

  2. freemarker写select组件(五)

    freemarker写select组件 1.宏定义 <#macro select id datas value="" key="" text=" ...

  3. freemarker写select组件(三)

    freemarker写select组件 1.宏定义 <#macro select id datas value="" key="" text=" ...

  4. freemarker写select组件(二)

    freemarker写select组件 1.宏定义 <#macro select id datas value=""> <select id="${id ...

  5. freemarker写select组件报错总结(一)

    1.具体错误如下 六月 25, 2014 11:26:29 下午 freemarker.log.JDK14LoggerFactory$JDK14Logger error 严重: Template pr ...

  6. freemarker写select组件报错总结(四)

    1.错误描述 <html> <head> <meta http-equiv="content-type" content="text/htm ...

  7. freemarker写select组件(二十二)

    一,讲解一 1.宏定义 <#macro select id datas> <select id="${id}" name="${id}"> ...

  8. freemarker写select组件报错总结(二)

    1.错误描述 六月 25, 2014 11:32:49 下午 freemarker.log.JDK14LoggerFactory$JDK14Logger error 严重: Template proc ...

  9. freemarker写select组件报错总结(七)

    1.错误描述 六月 26, 2014 11:26:27 下午 freemarker.log.JDK14LoggerFactory$JDK14Logger error 严重: Template proc ...

随机推荐

  1. How to fix “HTTP Status Code 505 – HTTP Version Not Supported” error?--转

    http://dotnetstock.com/technical/http-status-code-505-http-version-not-supported/ The reason for the ...

  2. Linux普通用户使用sudo权限启停apache服务

    sudo的工作过程如下: 1,用户执行sudo时,系统会主动寻找/etc/sudoers文件,判断该用户是否有执行sudo的权限 2,确认用户具有可执行sudo的权限后,让用户输入密码确认 3,若密码 ...

  3. bzoj 4546: codechef XRQRS [可持久化Trie]

    4546: codechef XRQRS 可持久化Trie codechef上过了,bzoj上蜜汁re,看别人说要开5.2e5才行. #include <iostream> #includ ...

  4. Ling && Lambda

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  5. js 中的一些小技巧

    js 数字操作: 1.1 取整: 取整有很多方法如: parseInt(a,10); Math.floor(a); a>>0; ~~a; a|0; 前面2种是经常用到的,后面3中算是比较偏 ...

  6. typedef void(*Fun)(void);

    typedef void(*Fun)(void); 函数类似于数组,函数名就是它的首地址: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ...

  7. LVS结合keepalived配置测试

     LVS/DR + keepalived配置 注意:前面虽然我们已经配置过一些操作,但是下面我们使用keepaliave操作和之前的操作是有些冲突的,所以若是之前配置过DR,请首先做如下操作:   三 ...

  8. 使用PowerDesigner对NAME和COMMENT互相转换

    本文来自我的github pages博客http://galengao.github.io/ 即www.gaohuirong.cn 在使用PowerDesigner对数据库进行概念模型和物理模型设计时 ...

  9. Java文件及文件夹的创建与删除

    功能 这个实例实现了在D盘创建一个文件和文件夹,并删除它们. 函数介绍 createNewFile():当文件不存在时,根据绝对路径创建该文件.     delete():删除文件或者文件夹.     ...

  10. 编写React组件的最佳实践

    此文翻译自这里. 当我刚开始写React的时候,我看过很多写组件的方法.一百篇教程就有一百种写法.虽然React本身已经成熟了,但是如何使用它似乎还没有一个"正确"的方法.所以我( ...