thymeleaf 使用javascript定义数组报错
js中免不了的要用的数组,一维的二维的三维的
但是当用到thymeleaf作为模版时候会有一些坑,导致数组不能用
org.thymeleaf.exceptions.TemplateProcessingException: Could not parse as expression: "
{checkbox: true, fixed: true}
, {field: 'originalFileName', title: '文件名', width: , sort: true}
, {field: 'fileType', title: '文件类型', width: }
, {field: 'fileSize', title: '文件大小', width: , sort: true}
, {field: 'createTime', title: '上传时间', width: , sort: true}
, {field: 'dpStatus', title: '数据处理状态', width: , templet: '#statusTpl', sort: true}
, {field: 'updateTime', title: '数据处理完成时间', width: , templet: '#updateTimeTpl', sort: true}
, {fixed: 'right', title: '操作', align: 'center', width: , toolbar: '#operating'}
" (template: "textManagement" - line 125, col 22)
at org.thymeleaf.standard.expression.StandardExpressionParser.parseExpression(StandardExpressionParser.java:)
at org.thymeleaf.standard.expression.StandardExpressionParser.parseExpression(StandardExpressionParser.java:)
at org.thymeleaf.standard.expression.StandardExpressionParser.parseExpression(StandardExpressionParser.java:)
at org.thymeleaf.engine.EngineEventUtils.parseAttributeExpression(EngineEventUtils.java:)
这里只接触最外层异常,而出现异常的位置
<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会把[[]]中的内容作为内联取值块解析,而不是数组。可以在cols的后面换行
解决办法:
方法一:回车换行如下:
, cols: [
[ //表头
{field: 'xxx', title: 'ID', width: , sort: true, fixed: 'left'}
, {field: 'xxx', title: '记录日期', width: }
, {field: 'xxx', title: '操作人ID', width: , sort: true}
, {field: 'xxx', title: '', width: }
, {field: 'xxx', title: '签名', width: }
, {field: 'xxx', title: '积分', width: , sort: true}
, {field: 'xxx', title: '评分', width: , sort: true}
, {field: 'xxx', title: '职业', width: }
, {field: 'xxx', title: '财富', width: , sort: true}
]
]
方法二:或者在script标签里 th:inline="none" 就可以了,默认是th:inline="text"
<script th:inline="none">
</script>
thymeleaf 使用javascript定义数组报错的更多相关文章
- JavaScript实现弹窗报错
JavaScript实现弹窗报错 1.具体错误如下 SCRIPT 5022:cannot call methods on dialog prior to initialization; attempt ...
- java使用类数组 报错Exception in thread "main" java.lang.NullPointerException
源代码如下: Point[] points=new Point[n];//Point是一个类 for(int i=0;i<n;i++) { System.out.print("请输入x ...
- springAOP注解方式定义切入点报错error at ::0 can't find referenced pointcut
[说明] 1.使用spring版本:4.0.4 2.springAOP相关依赖包: 1)aopalliance-1.0.jar 2)aspectjweaver-1.8.9.jar 3)aspectjr ...
- mybatis问题。foreach循环遍历数组报错情况,及其解决方法
根据条件查询数据列表,mybatis查询代码如下 如果只查询属于特定部门拥有的数据权限.这需要用 String[ ] codes保存当前部门及其子部门的部门编码. 所以需要在mybatis中遍历编码数 ...
- 解决关于ARM_MATH数学库宏定义的报错
昨天在建立新工程的时候发现加入含有ARM_MATH库的时候出现了宏定义报错. #error directive:"Define according the used Cortex core ...
- mysql 创建函数或者存储过程,定义变量报错
报错的原因是因为在过程或者函数中存在分隔符 分号(:),而mysql中默认分隔符也是 :,这就导致存储过程分开了 在存储过程外面包一层 delimiter // code //就行了
- Arcgis Javascript中geometryEngine报错’hq‘of undefined的解决方法
这个问题困扰了我一个星期,原因是使用geomagicbuffer时候,有的线可正常使用,有的就直接报错,一直没有解决,后来发现是api自己的bug导致的 干脆直接读代码,在geometryEngine ...
- NSUserDefaults保存对象数组报错
在使用NSUserDefaults的时候插入数据有时候会报以下错误:Attempt to set a non-property-list objec 这种错误的原因是插入了不识别的数据类型,NSUse ...
- <JavaScript>调用apply报错:CreateListFromArrayLike called on non-object;
Function.apply(obj, args)方法能接收两个参数 obj:这个对象将代替Function类里this对象 args:这个是数组,它将作为参数传给Function(args--> ...
随机推荐
- kubeadm init 时从本地私有仓库下载镜像
#kubeadm init 时从本地私有仓库下载镜像 images=( gcr.io/google_containers/kube-proxy-amd64:v1.6.1 gcr.io/google_c ...
- msf提权基础(一)
令牌(token)相当于系统的临时密钥(账号及密码) 加载incognito模块 meterpreter> use incognito meterpreter > list_tokens ...
- bat 数组实现
bat中没有数组的概念,可以通过有[]的多个变量来存储一组值 @echo off & setlocal enabledelayedexpansion .txt) do ( echo %%b e ...
- 【VSC】我安装了哪些扩展插件
Nodejs gitk —— 版本实时比对 Debugger for Chrome —— 让 vscode 映射 chrome 的 debug功能,静态页面都可以用 vscode 来打断点调试. ...
- 【CSS3】特殊的属性归纳(一)
CSS3手册地址速查表 -webkit- 最终要用兼容性写法 (一)-webkit-tap-highlight-color (mobile移动设备私有属性) 案列: 问题:遇到a链接和butto ...
- C++ - 模板(template)中typename的使用方法
声明template参数时, 前缀关键字class和typename可以互换; 使用关键字typename标识嵌套从属类型名称, 但不需在基类列表和成员初始化列表内使用. 从属名称(dependent ...
- FullCalendar Timeline View 使用
FullCalendar Timeline View(v4) The Scheduler add-on provides a new view called “timeline view” with ...
- 我的react学习
基础部分 创建一个react的项目 创建一个react的项目 全局安装 react 指令 // 全局安装react (根据需要安装,不是必须的) npm i -g react // 或者 yarn - ...
- #leetcode刷题之路42-接雨水
给定 n 个非负整数表示每个宽度为 1 的柱子的高度图,计算按此排列的柱子,下雨之后能接多少雨水.上面是由数组 [0,1,0,2,1,0,1,3,2,1,2,1] 表示的高度图,在这种情况下,可以接 ...
- 通过脚手架创建Vue项目
第一步 准备工作 1.下载安装Node.js 验证是否安装的方法,在命令行输入node -v 2.安装Vue 在命令行输入npm install -g @vue/cli 查看Vue版本号 npm vu ...