JavaEar 专注于收集分享传播有价值的技术资料

intellij thymeleaf Namespace th is not bound

I am using IntelliJ IDEA and I have with thymeleaf namespaces. I have created employee form which I am including into others templates so I did not specified namespaces but its works fine when I run my application. Is there any way to change this behaviour. I like auto-complete function :-)

Namespace 'th' is not bound example:

Namespace 'th' is not bound

3个回答

    最佳答案
  1. Also, if you are using Spring you should use the following:

    <!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-4.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
      <head>
         <title>Hello</title>
      </head>
      <body>
      </body>
    </html>
    

    The difference is in the DOCTYPE. See Intellij Idea: Thymeleaf namespace unkown

  2. 参考答案2
  3. To enable auto completion and IDE support for Thymeleaf, make sure you have enabled the Thymeleaf plugin.

    File -> Other Settings -> Config Plugins -> tick Thymeleaf

    screenshot of plugin window

    Also add the namespace in the root tag

    <html .... xmlns:th="http://www.thymeleaf.org">

  4. 参考答案3
  5. There's no harm defining your fragments in a well formed document (including a html, head, body etc). In fact this is how the Thymeleaf Documentation does it.

    This way you can specify the thymeleaf namespace so you get autocomplete, and you can also view your fragments by themselves in the browser, which is useful for prototyping.