IDEA中thymeleaf 表达式报红波浪线


一,场景再现

最近在做一个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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM