The way Thymeleaf template js and css are introduced

Thymeleaf is a modern server-side Java template engine. Unlike JSP and FreeMarker, Thymeleaf's syntax is closer to HTML, and it also has good extensibility. Details can be found on the official website . This article mainly introduces the instructions for using the Thymeleaf template.

template (template fragments)

Defining and referencing templates

In daily development, we often extract the navigation bar, footer, menu and other parts into templates for other pages to use.

In Thymeleaf, we can use th:fragmentattributes to define a template.

We can create a simple footer template, such as: /WEB-INF/templates/footer.html, the content is as follows:

<!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">
  <body>
    <div th:fragment="copyright">
      © 2016 xxx
    </div>
  </body>
</html> 

The above defines a copyrightfragment called , which we can then use with the th:includeor th:replaceattribute:

<body>
  ...
  <div th:include="footer :: copyright"></div> 
</body>

 

 

Reference link: https://www.cnblogs.com/lazio10000/p/5603955.html 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325006518&siteId=291194637