天天看點

Thymeleaf使用easy-ui出現腳本無法解析的問題

問題來源

今天用SpringBoot中的Thymeleaf查詢資料庫中資料并進行分頁,為了友善使用了easyui的datagrid,并通過腳本建立資料網格,但是一直報一個錯誤:無法解析datagrid的腳本語言。經過查詢資料,解決方案如下:

原腳本如下:

<link rel="stylesheet" type="text/css" href="/easyui/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="/easyui/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="/easyui/demo.css">
    <script type="text/javascript" src="/easyui/jquery.min.js"></script>
    <script type="text/javascript" src="/easyui/jquery.easyui.min.js"></script>
    <script>
        $(function(){
            $(function(){
                $('#usershow').datagrid({
                    url: 'user',
                    rownumbers:true,
                    pagination:true,
                    pageSize:2,
                    pageList:[2,4],
                    columns: [[
                        {field: 'uname', title: '使用者名', width: 200,align:'center'},
                        {field: 'pwd',title: '密碼',width: 200,align:'center'},
                        {field: 'phone', title: '手機号', width: 200,align:'center'}
                    ]]
                });
            });
        });

    </script>
           

問題如下:

There was an unexpected error (type=Internal Server Error, status=500).
Could not parse as expression:

 " {field: 'uname', title: '使用者名', width: 200,align:'center'}, {field: 'pwd',title: '密碼',width: 200,align:'center'}, {field: 'phone', title: '手機号', width: 200,align:'center'} " (template: "page" - line 20, col 32)
           

問題解決:

在中加一個th:inline="none"就可以解決了

Thymeleaf使用easy-ui出現腳本無法解析的問題

雖然解決了,但還是不明白是為啥,若有大佬路過望解析。

繼續閱讀