錯誤信息:
Caused by: org.attoparser.ParseException: Could not parse as expression: " {type: "checkbox", width: "80"}, {field: "id", title: "用戶ID", width: "80"}, {field: "user_name", title: "賬號", width: "120"}, {field: "password", title: "密碼", width: "120"}, {field: "real_name", title: "姓名", width: "150"}, { field: "type", title: "角色", width: "100", templet: function (d) { if (d.type == 1) { return "管理員"; } else if (d.type == 2) { return "業務員"; } } }, { field: "is_del", title: "狀態", width: "100", templet: function (d) { if (d.is_del == 1) { return "<font color='green'>有效</font>"; } else if (d.is_del == 2) { return "<font color='gray'>無效</font>"; } } }, {title: "操作", width: "250", toolbar: "#rowBtns"} " (template: "User/list" - line 154, col 21) at org.attoparser.MarkupParser.parseDocument(MarkupParser.java:393) at org.attoparser.MarkupParser.parse(MarkupParser.java:257) at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse(AbstractMarkupTemplateParser.java:230) ... 48 more Caused by: org.thymeleaf.exceptions.TemplateProcessingException: Could not parse as expression: " {type: "checkbox", width: "80"}, {field: "id", title: "用戶ID", width: "80"}, {field: "user_name", title: "賬號", width: "120"}, {field: "password", title: "密碼", width: "120"}, {field: "real_name", title: "姓名", width: "150"}, { field: "type", title: "角色", width: "100", templet: function (d) { if (d.type == 1) { return "管理員"; } else if (d.type == 2) { return "業務員"; } } }, { field: "is_del", title: "狀態", width: "100", templet: function (d) { if (d.is_del == 1) { return "<font color='green'>有效</font>"; } else if (d.is_del == 2) { return "<font color='gray'>無效</font>"; } } }, {title: "操作", width: "250", toolbar: "#rowBtns"} " (template: "User/list" - line 154, col 21)
原因:因為[[…]]之間的表達式在thymeleaf被認為是內聯表達式,所以渲染錯誤
解決:
1.也就是把cols后的[[ ]]變為
[
[
]
]
2.
或者在<script type="text/javascript" > 加上 th:inline="none"
<script type="text/javascript" th:inline="none">
但是這樣的話,前面在base中使用[[@{}]]的標簽也不能解析了,所以還是使用第一種方案,以后可以根據情況來解決