【发布时间】:2019-12-17 13:18:01
【问题描述】:
IntelliJ 无法识别 Thymeleaf 文档中指定的所有变量是否正常?
我在我的 Spring Boot 应用程序项目中使用 Thymeleaf 引擎模板并使用 IntelliJ 作为 IDE,但似乎 IntelliJ 没有实现所有 THymeleaf 功能,或者我的 IDE 配置有问题,或者我不明白。
例如:
${param.q}
应该读取 GET 方法的 q 变量,但 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";
}
}
【问题讨论】:
-
代码在编辑器中的样子如何?我已经检查了示例项目,它是looks like this。 “不认识”是什么意思?
-
非常感谢您的检查。所以是配置的问题。在我的例子中,IntelliJ 检测到错误并用红色下划线。
-
谢谢!我已经编辑了。
-
你能用
$代替#吗?
标签: spring-mvc intellij-idea thymeleaf