Springboot结合layui展示table的问题

前台代码

<table id="uesrList" lay-filter="userTable" lay-data="{url:'/user/getUserList'}"></table>

<script type="text/javascript"  th:inline="none">
   // $('.collapsed').collapse()
   $(function() {
      layui.use('table', function(){
         var table = layui.table;

         table.render({
            elem: '#test'
            ,url:'/user/getUserList'
            ,cellMinWidth: 80 //全局定义常规单元格的最小宽度,layui 2.2.1 新增
            ,method: 'post' //默认:get请求
            ,cols: [[
               {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: '密码'}
            ]]
         });
      });
   });

</script>

异常:
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:[[…]],就是[[]]里面的内容不能渲染
这个问题搞得我头大,因为第一次使用springboot,也不知道在干什么,后来在网上找到了答案
因为“[[]]”[[…]]之间的表达式在Thymeleaf被认为是内联表达式
解决方法:1、或者在script标签里 th:inline=”none” 就可以了
2、将[[]]换行成

[

  [

  ]

]

即可

原文链接https://blog.csdn.net/boke7265/article/details/80855958

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值