今天用Spring的Thymeleaf模板引擎,去渲染layui表格的时候一直报错,报错如下
org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing
(template: "class path resource [templates/user/table.html]")~~~省略
Caused by: org.attoparser.ParseException: Could not parse as expression: "
{field: 'id', title: 'ID', width:80}
" (template: "user/table" - line 25, col 22)
后来去文档查阅了一下
cols: [[
{field: 'id', title: '编号', width:80},
{field: 'name', title: '姓名', width:80},
]]
在layui中的cols中的[[~~]]在模板引擎中是无法读取识别的
需要更改成
cols: [
[
{field: 'id', title: '编号', width:80},
{field: 'name', title: '姓名', width:80},
]
]
中括号之间用回车键另开一行,就可以了