青烟

小燕归园花正语,水清不问旧消息。

thymeleaf+layui加载页面渲染时报错

将freemaker替换成thymeleaf时出现以下问题:

org.thymeleaf.exceptions.TemplateProcessingException: Could not parse as expression: "
                {field:'id', title:'编号'},
                {field:'username', title:'用户名'},
                {field:'password', title:'密码'},
                {field:'nickname', title:'昵称'},
                {fixed:'right',title:'操作',toolbar:'#barDemo'}
            " (template: "users" - line 96, col 22)

但是这个地方纯粹是使用layui进行的表格渲染,推测是某个表达式跟thymeleaf重复了。查证之下发现[[…]]之间的表达式在thymeleaf被认为是内联表达式,所有要将[[]]分隔开来。

        table.render({
            elem: '#demo'
            ,url:'/users/list'
            ,toolbar: '#toolbarDemo' //开启头部工具栏,并为其绑定左侧模板
            ,defaultToolbar: ['filter', 'exports', 'print']
            ,title: '用户数据表'
            ,cols: [
                [
                {field:'id', title:'编号'},
                {field:'username', title:'用户名'},
                {field:'password', title:'密码'},
                {field:'nickname', title:'昵称'},
                {fixed:'right',title:'操作',toolbar:'#barDemo'}
                ]
            ]
            ,page: true
        });

解决问题。

posted @ 2021-08-20 19:45  今后  阅读(152)  评论(0编辑  收藏  举报