Spring boot+Thymeleaf+easyui集成:js创建组件页面报错

开发工具:Ideal

使用场景:Demo

前提:
       环境:Spring boot +Thymeleaf+easyui

引入thymeleaf模板引擎

 <html lang="en" xmlns:th="http://www.thymeleaf.org">
Html页面引入easyui需要的文件 <link href="/js/jquery-easyui-1.5.3/themes/gray/easyui.css" rel="stylesheet"/> <link href="/js/jquery-easyui-1.5.3/themes/icon.css" rel="stylesheet"/> <script src="/js/jquery-easyui-1.5.3/jquery.min.js"></script> <script src="/js/jquery-easyui-1.5.3/jquery.easyui.min.js"></script> <script src="/js/jquery-easyui-1.5.3/locale/easyui-lang-zh_CN.js"></script>

当以标签属性创建easyui组件时,页面正常显示。
以标签属性创建easyui组件:

 <table class="easyui-datagrid" title="Basic DataGrid" style="width:700px;height:250px"

        data-options="singleSelect:true,collapsible:true,url:'/getUsers',method:'get'">

     <thead>

         <tr>

             <th data-options="field:'id',width:80">Item ID</th>

             <th data-options="field:'name',width:100">姓名</th>

             <th data-options="field:'tel',width:80,align:'right'">电话</th>

         </tr>

     </thead>

 </table>

页面效果:

Spring boot+Thymeleaf+easyui集成:js创建组件页面报错

当以js形式创建组件时出现问题
以js创建easyui组件

 <table id="dg"></table>

 <script type="text/javascript">

     $(function(){

         $('#dg').datagrid({

             url: '/getUsers',

             method: 'get',

             title: '用户表',

             iconCls: 'icon-save',

             width: 800,

             height: 250,

             fitColumns: true,

             singleSelect: true,

             columns:[[

                 {field:'id',title:'Item ID',width:80},

                 {field:'name',title:'姓名',width:80},

                 {field:'tel',title:'电话',width:80}

             ]]

         });

     });

 </script>

效果:

Spring boot+Thymeleaf+easyui集成:js创建组件页面报错

后台报以下错误:

[THYMELEAF][http-nio-8080-exec-1] Exception processing template "user": Could not parse as expression: "

{field:'id',title:'Item ID',width:80},

{field:'name',title:'姓名',width:80},

{field:'tel',title:'电话',width:80}

" (template: "user" - line 26, col 27)

解决方式:

 <script type="text/javascript" >

改为

 <script type="text/javascript" th:inline="none">

总结:

在easyui页面中,script执行easyui自己的方法要加入:

 <script th:inline="none">

原文参考:https://blog.csdn.net/xlzwhq0000004/article/details/83144440

上一篇:DFS 数字排列


下一篇:pandas读取excel数据问题记录