spring-mvc - IntelliJ 无法识别 thymeleaf 的变量
问题描述
IntelliJ 无法识别 Thymeleaf 文档中指定的所有变量是否正常?
我在我的 Spring Boot 应用程序项目中使用 Thymeleaf 引擎模板和 IntelliJ 作为 IDE,但似乎 IntelliJ 没有实现所有 THymeleaf 功能,或者我的 IDE 配置有问题,或者我不明白。
例如:
${param.q}
应该读取方法的q
变量,GET
但 IntelliJ 无法识别该变量。在运行应用程序时,它可以正常工作。
模板(param.q 红色下划线)
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Title</title>
</head>
<body>
<p th:text="${param.q}">Some text</p>
</body>
</html>
弹簧控制器
package com.drogago.todo.controllers;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
public class TestController {
@RequestMapping(value = "/test", method = RequestMethod.GET)
public String showIndex2() {
return "index2";
}
}
解决方案
我找到了解决方案。由于 IntelliJ 无法加载资源,出现问题。当在“添加框架支持”菜单中选择 Thymeleaf 时,有信息表明资源正在加载,但进程处于无限循环中。我已禁用同步并重新启动 IntelliJ。然后我在“文件”菜单中关闭了项目并再次运行它。最后,我重新导入项目(在 Maven 菜单中)。现在它可以正常工作了。
推荐阅读
- shiny - 如何根据公式而不是单元格值更改 Shiny DT 表的单元格颜色?
- javascript - 如何使 JavaScript 忽略对象字段中的转义字符
- angular - Ionic 5 在构建期间将文件导出到 www
- excel - Excel:我可以在“真”时使用“如果”公式,而不必将公式复制到 [value-if-true]?
- java - Java - 带有 Integer.valueOf() 的空格导致 java.lang.NumberFormatException
- jquery - Select2 显示闪烁的“多个”滚动条,直到 ready()
- pyspark - PySpark 自定义 TimestampType 列转换
- javascript - Javascript new Date 自动添加一天
- powershell - 您如何为任务序列变量设置编写 Pester 模拟
- javascript - 如何设置自动完成结果的样式