当前位置:网站首页>Beetl使用记录
Beetl使用记录
2022-08-08 15:43:00 【InfoQ】
Beetl
使用记录
POM
<dependency>
<groupId>com.ibeetl</groupId>
<artifactId>beetl</artifactId>
<version>${version}</version>
</dependency>
基础语法
- 条件判断 :除常规if-else,switch-case外,增加了switch-case增强语法,省略break关键字,多个条件使用,隔开
- 循环:常规for(exp;exp;exp),while,for-in都支持
- for-in:中额外增加了内置变量
- 变量名LP.index当前的索引,从1开始
- 变量名LP.even 索引是否是偶数
- 变量名LP.odd 索引是否是奇数
- 变量名LP.first 是否是第一个
- 变量名LP.last 是否是最后一个
- 变量名LP.dataIndex索引,从0开始
- 变量名P.size集合的长度
- elsefor:表示未进入for循环的处理
<%
var list = [];
for(item in list){
}elsefor{
print("未有记录");
}
%>
解析字符串模版
StringTemplateResourceLoader resourceLoader = new StringTemplateResourceLoader();
Configuration cfg = Configuration.defaultConfiguration();
GroupTemplate gt = new GroupTemplate(resourceLoader, cfg);
String templateStr = "${json(_root)}";
Template template = gt.getTemplate(templateStr);
Map<String,Object> map = new HashMap<>();
map.put("a",123);
map.put("b","ada");
template.binding("_root",map);
System.out.println(template.render());
- tempStr:字符串模板
- _root:根变量,使用根变量则属性访问可省略前缀
- json():内置函数,可将变量转换为json字符串,可作为代码执行后的输出存储
- 实现Function接口,这类方法参照配置文件中配置简写即可访问,配置文件中以FN.作为前缀的配置
- 独立的工具类:strutil 字符串工具类,配置文件中以FNP.作为前缀的配置,访问时通过strutil.方法名访问.
${@com.xxxx.constants.Order.getMaxNum()}
<%
var max = @com.xxxx.constants.Order.MAX_NUM;
%>
参考资料
边栏推荐
猜你喜欢
随机推荐
Is the current safe and reliable domestic futures account opening process?
【kali-权限提升】(4.2.5)社会工程学工具包:PowerShell攻击向量(防报毒)
使用FastApi服务解决程序反复调试导致速度过慢的问题(以tsfresh为例)
幂等性~~
Thread local storage ThreadLocal
Jingdong T9 pure hand type 688 pages of god notes, SSM framework integrates Redis to build efficient Internet applications
Redis RDB分析系统
CS231n:6 训练神经网络(三)
快速排序(C语言版)
leetcode/number of palindromic substrings
leetcode 31. 下一个排列(实现next_permutation 函数)
来,集中训练一下二叉树的层序遍历~
Superset 1.2.0 installation
文档管理系统:攻克这3个痛点,解决80%企业文档管理难题
The origin and creation of Smobiler's complex controls
Introduction to Recurrent Neural Network (RNN)
[Unity entry plan] Use the double blood bar method to control the blood loss speed of the damage area
2022年8月中国数据库排行榜:openGauss重夺榜眼,PolarDB反超人大金仓
ThinkPHP3.2链接带中文参数乱码导致分页数据错误
Mysql的分布式事务原理理解