日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學無先后,達者為師

網站首頁 編程語言 正文

Layui碰上Thymeleaf的解析問題

作者:大夢. 更新時間: 2022-01-10 編程語言
一個Layui碰上Thymeleaf導致的一個問題

今天要做一個表格導出功能項目前端是Layui就想到它有一個組件是可以直接導出成Excel的二話不說整合完成(整合的方法網上很多)

測試例子:

LAY_EXCEL.exportExcel([['Hello', 'World', '!']], 'hello.xlsx', 'xlsx');

然后報錯。

前端報的錯:

image

后端報的錯:

image

2021-10-13 15:58:20.328 [TemplateEngine.java:1136] - [THYMELEAF][http-nio-9001-exec-1] Exception processing template "marketing/newSMStimetask/task_list_newsms": An error happened during template parsing (template: "class path resource [templates/marketing/newSMStimetask/task_list_newsms.html]")
org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [templates/marketing/newSMStimetask/task_list_newsms.html]")
	at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse(AbstractMarkupTemplateParser.java:241) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE]
	at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parseStandalone(AbstractMarkupTemplateParser.java:100) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE]
	at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:666) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE]
	at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1098) [thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE]
	at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1072) [thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE]
	at org.thymeleaf.spring5.view.ThymeleafView.renderFragment(ThymeleafView.java:354) [thymeleaf-spring5-3.0.9.RELEASE.jar:3.0.9.RELEASE]

找了好久最后發現thymeleaf 將代碼中的二維數組,兩個中括號連著當成自己的標簽去解析了。

解決方法:

? 將兩個連著的中括號中間加一個空格就行了

#修改前:

LAY_EXCEL.exportExcel([['Hello', 'World', '!']], 'hello.xlsx', 'xlsx');

#修改后:

LAY_EXCEL.exportExcel([ ['Hello', 'World', '!'] ], 'hello.xlsx', 'xlsx');

完美解決。

剛好今天LayUI官網下線了,特此記錄一下。

原文鏈接:https://blog.csdn.net/qq_22832075/article/details/120746241

欄目分類
最近更新