thymeleaf + layui渲染报错

文章中引用了链接https://www.cnblogs.com/suncj/p/4031486.html,侵删

thymeleaf + layui渲染报错

thymeleaf是springboot推荐使用的模板引擎
layui是一款非常不错的前端模板


在使用thymeleaf + layui 做表格渲染的时候,出现了这么一个错误

org.thymeleaf.exceptions.TemplateProcessingException: Could not parse as expression: "
                    {type: 'checkbox', fixed: 'left'}
                    , {field: 'id', title: 'ID', width: 80, fixed: 'left', unresize: true, sort: true}
                    , {field: 'username', title: '用户名', width: 120, edit: 'text'}
                    , {
                        field: 'phone', title: '手机号', width: 150, edit: 'text', templet: function (res) {
                            return '<em>' + res.email + '</em>'
                        }
                    }
                    , {
                        field: 'email', title: '邮箱', width: 150, edit: 'text', templet: function (res) {
                            return '<em>' + res.email + '</em>'
                        }
                    }
                    , {field: 'createTime', title: '创建时间', width: 120}
                    , {field: 'loginTime', title: '登录时间', width: 120}
                    , {field: 'lastLoginTime', title: '上次登录时间', width: 120}
                    , {field: 'count', title: '登录次数', width: 120}
                    , {fixed: 'right', title: '操作', toolbar: '#operateBar', width: 150}
                " (template: "/manage/user/userList" - line 60, col 27)

报错的部分为layui渲染表格的语法部分,是使用以下方式编写的

cols: [[
                    {type: 'checkbox', fixed: 'left'}
                    , {field: 'id', title: 'ID', width: 80, fixed: 'left', unresize: true, sort: true}
                    , {field: 'username', title: '用户名', width: 120, edit: 'text'}
                    , {
                        field: 'email', title: '邮箱', width: 150, edit: 'text', templet: function (res) {
                            return '<em>' + res.email + '</em>'
                        }
                    }
                    , {field: 'createTime', title: '创建时间', width: 120}
                ]]

[[]]在thymeleaf中被定义为内联表达式,关于内联表达式请参阅 作者【指尖舞步】的文章thymeleaf中的内联[ [ ] ]

thymeleaf的语法非常严谨,所以,将两个[[(及]])拆开即可破坏内联表达式。

cols: [
                    [
                    {type: 'checkbox', fixed: 'left'}
                    , {field: 'id', title: 'ID', width: 80, fixed: 'left', unresize: true, sort: true}
                    , {field: 'username', title: '用户名', width: 120, edit: 'text'}
                    , {field: 'email', title: '邮箱', width: 150, edit: 'text', templet: function (res) {
                            return '<em>' + res.email + '</em>'
                        }}
                    , {field: 'createTime', title: '创建时间', width: 120}
                    ]
                ]

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值