Thymeleaf代码自动完成在IntelliJ 14中无效。

4

我正在尝试在Intellij 14中使用Thymeleaf模板引擎与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>
1个回答

9

IntelliJ IDEA 14完全支持thymeleaf。你需要注意的是使用命名空间。

<!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">

在你的模板中使用这个,然后你就可以得到IntelliJ自动完成。希望这回答了你的问题。谢谢。


2
我花了一天时间才意识到为什么我的项目中的自动完成功能无法工作。我拼错了命名空间名称(www.被遗漏了)。谢谢。 - Yaro

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接