freemarker写select组件(四)
freemarker写select组件
1、宏定义
- <#macro select id datas value="" key="" text="" headKey="" headValue="">
- <select id="${id}" name="${id}">
- <option>---请选择---</option>
- <#if headKey!="">
- <option value="${headKey}">${headValue}</option>
- </#if>
- <#list datas as data>
- <#if key!="">
- <#if value == data[key]?string>
- <option value="${data[key]}" selected>${data[text]}</option>
- <#else>
- <option value="${data[key]}">${data[text]}</option>
- </#if>
- <#else>
- <#if value == data>
- <option value="${data}" selected>${data}</option>
- <#else>
- <option value="${data}">${data}</option>
- </#if>
- </#if>
- </#list>
- </select>
- </#macro>
2、引入宏
- <@items.select id="username" datas=users key="userNo" text="userName" headKey="0" headValue="其他"/>
3、示例结果
- <select id="username" name="username">
- <option>---请选择---</option>
- <option value="0">其他</option>
- <option value="1">张三丰</option>
- <option value="2">李思思</option>
- <option value="3">赵武</option>
- <option value="4">刘雪</option>
- <option value="5">朱顾</option>
- <option value="6">赵武</option>
- <option value="7">吴语</option>
- <option value="8">血玉</option>
- </select>
freemarker写select组件(四)的更多相关文章
- freemarker写select组件(一)
freemarker写select组件 1.宏定义 <#macro select id datas> <select id="${id}" name=" ...
- freemarker写select组件(五)
freemarker写select组件 1.宏定义 <#macro select id datas value="" key="" text=" ...
- freemarker写select组件(三)
freemarker写select组件 1.宏定义 <#macro select id datas value="" key="" text=" ...
- freemarker写select组件(二)
freemarker写select组件 1.宏定义 <#macro select id datas value=""> <select id="${id ...
- freemarker写select组件报错总结(一)
1.具体错误如下 六月 25, 2014 11:26:29 下午 freemarker.log.JDK14LoggerFactory$JDK14Logger error 严重: Template pr ...
- freemarker写select组件报错总结(四)
1.错误描述 <html> <head> <meta http-equiv="content-type" content="text/htm ...
- freemarker写select组件(二十二)
一,讲解一 1.宏定义 <#macro select id datas> <select id="${id}" name="${id}"> ...
- freemarker写select组件报错总结(二)
1.错误描述 六月 25, 2014 11:32:49 下午 freemarker.log.JDK14LoggerFactory$JDK14Logger error 严重: Template proc ...
- freemarker写select组件报错总结(七)
1.错误描述 六月 26, 2014 11:26:27 下午 freemarker.log.JDK14LoggerFactory$JDK14Logger error 严重: Template proc ...
随机推荐
- 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 ...
- Linux普通用户使用sudo权限启停apache服务
sudo的工作过程如下: 1,用户执行sudo时,系统会主动寻找/etc/sudoers文件,判断该用户是否有执行sudo的权限 2,确认用户具有可执行sudo的权限后,让用户输入密码确认 3,若密码 ...
- bzoj 4546: codechef XRQRS [可持久化Trie]
4546: codechef XRQRS 可持久化Trie codechef上过了,bzoj上蜜汁re,看别人说要开5.2e5才行. #include <iostream> #includ ...
- Ling && Lambda
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- js 中的一些小技巧
js 数字操作: 1.1 取整: 取整有很多方法如: parseInt(a,10); Math.floor(a); a>>0; ~~a; a|0; 前面2种是经常用到的,后面3中算是比较偏 ...
- 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 ...
- LVS结合keepalived配置测试
LVS/DR + keepalived配置 注意:前面虽然我们已经配置过一些操作,但是下面我们使用keepaliave操作和之前的操作是有些冲突的,所以若是之前配置过DR,请首先做如下操作: 三 ...
- 使用PowerDesigner对NAME和COMMENT互相转换
本文来自我的github pages博客http://galengao.github.io/ 即www.gaohuirong.cn 在使用PowerDesigner对数据库进行概念模型和物理模型设计时 ...
- Java文件及文件夹的创建与删除
功能 这个实例实现了在D盘创建一个文件和文件夹,并删除它们. 函数介绍 createNewFile():当文件不存在时,根据绝对路径创建该文件. delete():删除文件或者文件夹. ...
- 编写React组件的最佳实践
此文翻译自这里. 当我刚开始写React的时候,我看过很多写组件的方法.一百篇教程就有一百种写法.虽然React本身已经成熟了,但是如何使用它似乎还没有一个"正确"的方法.所以我( ...