ftl 展示bigdecimal类型变量时,默认只展示整数部分(四舍五入小数部分)

${x} x如果是bigdecimal类型, 不会小数部分,四舍五入;


${x?string(',000.00')}或者${ x?string(',###.##') }都是按照整数部分每三位用'',''分割    小数部分最多展示两位(这个0或#个数相关)

0和#的区别就是在x的小数位或整数位不足的,'0'会强制补上0,''#'不会补任何东西(自适应);

0和#也可以组合使用  规则和上面说的一样;


整数部分也可以不用格式,${x?string('###.00')},   不在''里面加,  整数部分就不会格式例如123456789.00

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在使用FreeMarker(ftl模板和layui设置固定列之后,如果按钮不展示,可能也是因为按钮被隐藏在了固定列的后面,导致无法显示出来。这个问题同样可以通过调整固定列和非固定列的顺序来解决。 具体的实现方法可以参考以下代码: ```html <table class="layui-table" lay-size="sm"> <colgroup> <col width="100"> <col width="150"> <col> <col width="200"> <col width="200"> <col width="200"> <col width="100"> </colgroup> <thead> <tr> <th rowspan="2">ID</th> <th rowspan="2">用户名</th> <th rowspan="2">性别</th> <th colspan="3">联系方式</th> <th rowspan="2">操作</th> </tr> <tr> <th>手机</th> <th>邮箱</th> <th>地址</th> </tr> </thead> <tbody> <#list userList as user> <tr> <td>${user.id}</td> <td>${user.username}</td> <td>${user.sex}</td> <td>${user.phone}</td> <td>${user.email}</td> <td>${user.address}</td> <td> <button class="layui-btn layui-btn-xs" lay-event="edit">编辑</button> <button class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete">删除</button> </td> </tr> </#list> </tbody> </table> ``` ```js layui.use(['table', 'form'], function() { var table = layui.table; // 渲染表格 table.render({ elem: '.layui-table', cols: [[ {field: 'id', title: 'ID', fixed: 'left', width: 100}, {field: 'username', title: '用户名', fixed: 'left', width: 150}, {field: 'sex', title: '性别', width: 100}, {field: 'phone', title: '手机', width: 200}, {field: 'email', title: '邮箱', width: 200}, {field: 'address', title: '地址', width: 200}, {fixed: 'right', title: '操作', toolbar: '#toolbar', width: 100}, ]], data: [ // 数据 ], }); // 监听窗口大小变化 $(window).on('resize', function() { var width = $('.layui-form').width(); $('.layui-table-box').css('width', width + 'px'); }).resize(); // 监听工具条按钮点击事件 table.on('toolbar', function(obj) { switch(obj.event) { case 'add': // 添加操作 break; case 'delete': // 删除操作 break; } }); }); ``` 在这个例子中,使用了FreeMarker的语法来生成表格中的数据行,同将操作列设置为固定列,并且将其放在了列的最后面,这样就可以保证操作按钮可以正常显示了。同,在监听工具条按钮点击事件,需要根据按钮的event属性来判断是哪个按钮被点击了,然后执行相应的操作。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值