異常: 2018-06-29 14:07:51.492 ERROR 8980 --- [nio-8888-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [templates/user/userList.html]")] with root cause org.thymeleaf.exceptions.TemplateProcessingException: Could not parse as expression: " {field:'id', width:80, title: 'ID', sort: true} ,{field:'loginName', width:80, title: '登錄名'} ,{field:'email', width:80, title: '郵箱', sort: true} ,{field:'phone', width:80, title: 'phone'} ,{field:'userType', title: '用戶類型', sort: true} ,{field:'name', title: '姓名', sort: true} ,{field:'password', title: '密碼'} " (template: "user/userList" - line 61, col 14) 解決方案: 是報錯的位置提示在 cols:[[...]],就是[[]]裏面的內容不能渲染 因爲“[[]]”[[…]]之間的表達式在Thymeleaf被認爲是內聯表達式 1、或者在script標籤裏 th:inline="none" 就可以了 2、將[[]]換行成 [ [ ] ] 即可 <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"> <head> <meta charset="UTF-8"> <meta name="renderer" content="webkit"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" /> <title>網站後臺管理模版</title> <link rel="stylesheet" type="text/css" href="../../static/admin/layui/css/layui.css" th:href="@{admin/layui/css/layui.css}" media="all"/> <link rel="stylesheet" type="text/css" href="../../static/admin/css/admin.css" th:href="@{admin/css/admin.css}" /> <script src="admin/js/jquery-3.3.1.js"></script> <script src="md5/md5.js" type="text/javascript"></script> </head> <body> <table class="layui-hide" id="test" lay-filter="test"></table> <script type="text/html" id="toolbarDemo"> <div class="layui-btn-container"> <button class="layui-btn layui-btn-sm" lay-event="getCheckData">獲取選中行數據</button> <button class="layui-btn layui-btn-sm" lay-event="getCheckLength">獲取選中數目</button> <button class="layui-btn layui-btn-sm" lay-event="isAll">驗證是否全選</button> </div> </script> <script type="text/html" id="barDemo"> <a class="layui-btn layui-btn-xs" lay-event="edit">編輯</a> <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">刪除</a> </script> <script src="../../static/admin/layui/layui.js" th:src="@{admin/layui/layui.js}" type="text/javascript" charset="utf-8"></script> <script th:inline="none"> layui.use('table', function(){ var table = layui.table; table.render({ elem: '#test' ,url:'/lsh/jkrPersons' ,toolbar: '#toolbarDemo' ,title: '用戶數據表' ,cols:[ [//表頭 {type: 'checkbox', fixed: 'left'} ,{field:'id', title:'ID', width:80, fixed: 'left', unresize: true,sort: true} ,{field:'lvshiName', title:'律師', width:120} ,{field:'lvshiPhone', title:'律師電話', width:120} ,{field:'name', title:'借款人', width:150} ,{field:'mobilePhone', title:'借款人手機', width:80,} ,{field:'cardId', title:'借款人身份證', width:100} ,{field:'fName', title:'出借人', width:100} ,{field:'fCName', title:'出借聯繫人', width:100} ,{field:'str_beginTime', title:'借款日期',width:100} ,{field:'str_overTime', title:'截止日期'} ,{fixed: 'name', title:'操作', toolbar: '#barDemo', width:150,sort: true, fixed: 'right', unresize: true, } ] ] ,page: true ,limit:10 //默認十條數據一頁 ,limits:[10,20,30,50] //數據分頁條 ,id: 'testReload' }); //頭工具欄事件 table.on('toolbar(test)', function(obj){ var checkStatus = table.checkStatus(obj.config.id); switch(obj.event){ case 'getCheckData': var data = checkStatus.data; layer.alert(JSON.stringify(data)); break; case 'getCheckLength': var data = checkStatus.data; layer.msg('選中了:'+ data.length + ' 個'); break; case 'isAll': layer.msg(checkStatus.isAll ? '全選': '未全選'); break; }; }); //監聽行工具事件 table.on('tool(test)', function(obj){ var data = obj.data; //console.log(obj) if(obj.event === 'del'){ layer.confirm('真的刪除行麼', function(index){ obj.del(); layer.close(index); }); } else if(obj.event === 'edit'){ layer.prompt({ formType: 2 ,value: data.email }, function(value, index){ obj.update({ email: value }); layer.close(index); }); } }); }); </script> <!----新添加完畢---> </body> </html>
Springboot結合layui展示分頁 table出現的 [[ 的問題
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.