org.thymeleaf.exceptions.TemplateProcessingException: Could not parse as expression: "{.....}"异常的解决

页面由JSP改造成thymeleaf,系统没有报页面有错误,于是启动,访问对应页面时,报出一长串异常,核心是org.thymeleaf.exceptions.TemplateProcessingException: Could not parse as expression: "{.......}",刚开始遇到这个异常,也是一时手足无措,前后台各种找BUG,还是老样子,最后上网搜索,才知道,一些有JSP页面的写法,在thymeleaf是行不通的,按JSP的写法,thymeleaf渲染错误,下面是我原来的写法:

		columns:[[{
				field: "examTime",
				title: "检测时间",
				width: 140,
				align: "center",
				formatter: function(val){
					if(val){
 						return val.substring(0,19);
					}
					return val;
 				}
			}, {
				field: "tempC",
				title: "体温",
				width: 140,
				align: "center"
 			}, {
 			    
				field: "descript",
				title: "风险描述",
				width: 250,
				align: "center",
				 formatter: function(val, row, idx){
					if(val && row.level>0){
						return "<label title=\"" + val + "\" style=\"color: #FF0000;\">" + 
                    val + "</label>";
					}
					return "";
				} 
			
          }]]
			

因为[[…]]之间的表达式在thymeleaf被认为是内联表达式,所以无法正常渲染,页面也就访问不了了,正确的写法是把columns后面的[分行写,不要写在一行里,如下:

	columns:[
			 [
			  {
				field: "examTime",
				title: "检测时间",
				width: 140,
				align: "center",
				formatter: function(val){
					if(val){
 						return val.substring(0,19);
					}
					return val;
 				}
			}, {
				field: "tempC",
				title: "体温",
				width: 140,
				align: "center"
 			}, {
 			    
				field: "descript",
				title: "风险描述",
				width: 250,
				align: "center",
				 formatter: function(val, row, idx){
					if(val && row.level>0){
						return "<label title=\"" + val + "\" style=\"color: #FF0000;\">" 
                   + val + "</label>";
					}
					return "";
				} 
			}
		   ]
		 ]
发布了137 篇原创文章 · 获赞 28 · 访问量 24万+

猜你喜欢

转载自blog.csdn.net/shenxiaomo1688/article/details/102495003
今日推荐