當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
thymeleaf 使用javascript定义数组报错
生活随笔
收集整理的這篇文章主要介紹了
thymeleaf 使用javascript定义数组报错
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
js中免不了的要用的數組,一維的二維的三維的
但是當用到thymeleaf作為模版時候會有一些坑,導致數組不能用
org.thymeleaf.exceptions.TemplateProcessingException: Could not parse as expression: " {checkbox: true, fixed: true}, {field: 'originalFileName', title: '文件名', width: 400, sort: true}, {field: 'fileType', title: '文件類型', width: 100}, {field: 'fileSize', title: '文件大小', width: 110, sort: true}, {field: 'createTime', title: '上傳時間', width: 170, sort: true}, {field: 'dpStatus', title: '數據處理狀態', width: 122, templet: '#statusTpl', sort: true}, {field: 'updateTime', title: '數據處理完成時間', width: 170, templet: '#updateTimeTpl', sort: true}, {fixed: 'right', title: '操作', align: 'center', width: 300, toolbar: '#operating'}" (template: "textManagement" - line 125, col 22)at org.thymeleaf.standard.expression.StandardExpressionParser.parseExpression(StandardExpressionParser.java:131)at org.thymeleaf.standard.expression.StandardExpressionParser.parseExpression(StandardExpressionParser.java:62)at org.thymeleaf.standard.expression.StandardExpressionParser.parseExpression(StandardExpressionParser.java:44)at org.thymeleaf.engine.EngineEventUtils.parseAttributeExpression(EngineEventUtils.java:220)這里只接觸最外層異常,而出現異常的位置
<script>var cols=[[{field:'checkBox',checkbox: true, fixed: true},{field:'username', title: '用戶名'} //width 支持:數字、百分比和不填寫。你還可以通過 minWidth 參數局部定義當前單元格的最小寬度,layui 2.2.1 新增,{field:'mobile', title: '手機號', sort: true},{field:'nickname', title: '昵稱'},{field:'lastLoginTime', title: '最后登錄時間'},{field:'ip', title: '最后登錄ip', align: 'center'} //單元格內容水平居中,{field:'op',title: '操作', align:'center', toolbar: '#toolBars'} //這里的toolbar值是模板元素的選擇器 ]]; </script>?
thymeleaf會把[[]]中的內容作為內聯取值塊解析,而不是數組??梢栽赾ols的后面換行
解決辦法:
方法一:回車換行如下:
方法二:或者在script標簽里 th:inline="none" 就可以了,默認是th:inline="text"
<script th:inline="none"> </script>?
轉載于:https://www.cnblogs.com/schoolbag/p/9679014.html
總結
以上是生活随笔為你收集整理的thymeleaf 使用javascript定义数组报错的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 细说SQL 连接
- 下一篇: gradle idea java ssm