一,場景再現
最近在做一個SpringBoot項目,於是自然就接觸到了thymeleaf .但是在開發中,遇到一個很奇怪的現象.
從上面圖片我們看到,我們在html頁面利用thymeleaf表達式取值,底部有紅色波浪線,但是啟動項目,卻能正常顯示,這是為什么?
二.刨根問底
我們雖然在后端的model數據中添加了,但是對於前端文件是無法感知的。因為這個時候並沒有程序運行,也沒有如此的智能。所以這個時候就會有紅色波浪線存在了
三.解決方案
①.根據IDEA提示,有如下申明
<!--/*@thymesVar id="channels" type=""*/--> <tr th:each="channel,channelStat:${channels}"> <td th:text="${channel.channel}"></td> <td th:text="${channel.channelName}"></td> <td th:text="${channel.defaultWorkNumber}"></td> <td th:text="${channel.defaultBureaotoCode}"></td> <td th:text="${channel.createTime}"></td> <td th:text="${channel.phoneNoType} == 0 ? '專屬' : '共享'"></td>
②.在<!DOCTYPE html>
下加上
<!--suppress ALL-->
③.修改IDEA設置
把設置里面的 Editor->Inspections->Thymeleaf->Expression variables validation后面的勾去掉
————————————————
原文鏈接:https://blog.csdn.net/Milogenius/article/details/84668291