本肉肉的Springboot版本是 1.5.2正式版,經測試,與Springboot版本無關,即使是低版本的Springboot也可以指定高版本的Thymeleaf,如下圖所示
手動指定Thymeleaf的版本,如下圖所示, pom.xml的properties節點
在使用中遇到了 org.thymeleaf.exceptions.TemplateProcessingException: Only variable expressions returning numbers or booleans are allowed in this context 異常
這個錯的意思是只允許數字和布爾型,這不扯蛋嘛,瞎雞兒報錯
還別說,我把參數寫死成數字或者布爾值還真的挺好用,然並卵,於是我就搜啊搜
https://blog.csdn.net/u010592926/article/details/86373871 這個帖子里一共給出了四種解決方案, 我卻是那第五種人
如上圖所示,雖然做完了,功能上沒任何影響,編譯運行,瀏覽器F12統統沒有任何錯誤,但是IDEA會提示語法錯誤,不知道為什么,上面那個CSDN的帖子中4種方案我都試了,統統不行,th:onclick 真是個坑,正確的IDEA卻報錯的代碼如下
<li th:each="item : ${playList}" th:onclick="switchUrl([[${item.get('showDateTime')}]],[[${item.get('playUrl')}]])" th:text="${item.get('showDateTime')}"></li>
后端返回的是List<Map<String,String>> list 形式的,所以item 中使用get(String key) 獲取,一開始太相信IDEA了,一報錯我就刪了重寫,后來干脆不理它了居然成功了!
是我,我是肉肉
2020年5月31日 晚上01:37