thymeleaf 代码完成不起作用 intellij 14

Sau*_*ava 2 spring-mvc intellij-idea thymeleaf intellij-14

我正在尝试将 thymeleaf 模板引擎与带有 intellij 14 的 Spring MVC 一起使用,但代码完成不起作用。请帮我。

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
  <title>Spring Core Online Tutorial</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>

  <link href="http://cdn.jsdelivr.net/webjars/bootstrap/3.3.4/css/bootstrap.min.css"
        th:href="@{/webjars/bootstrap/3.3.5/css/bootstrap.min.css}"
        rel="stylesheet" media="screen"/>

  <script src="http://cdn.jsdelivr.net/webjars/jquery/2.1.4/jquery.min.js"
          th:src="@{/webjars/jquery/2.1.4/jquery.min.js}"></script>

  <link href="../static/css/spring-core.css"
        th:href="@{css/spring-core.css}" rel="stylesheet" media="screen"/>
</head>

<body>
<div class="container">
  <h1>Hello World</h1>
  <h2>This is my Thymeleaf index page. This is my changed.</h2>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

Mos*_*our 6

intellj idea 14 完全支持 thymleaf。这里缺少的部分是名称空间的使用

<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
Run Code Online (Sandbox Code Playgroud)

在您的模板中使用它,然后您将获得 intellij 完成。希望这能回答你的问题。谢谢

  • 我花了 1 天的时间才意识到为什么完成在我的项目中不起作用。我拼错了命名空间名称(遗漏了```www.```)。谢谢 (2认同)