Writing common modules in HTML using Thymeleaf

Source: Internet
Author: User

When you write a page, you often need to use generic modules, such as the header section, the footer section, and so on.

The front end of the project is using the Themeleaf template engine, and the following is a brief introduction to using Themeleaf to write the header generic module:

1. Common part: header2.html

Primarily using the Th:gragment property tag

<!DOCTYPE HTML><HTMLLang= "ZH-CN"xmlns:th= "http://www.thymeleaf.org"><Headth:fragment= "Common_header (title)">  <MetaCharSet= "UTF-8">  <Metahttp-equiv= "X-ua-compatible"content= "Ie=edge"/>  <titleTh:replace= "${title}">Head Real</title></Head><Body><Divclass= "header"style= "Height:auto;"th:fragment= "header">This is the content from the header module ...</Div></Body></HTML>

2. Reference section:

Primarily tagged with the Th:relpace property

Headdemo01.html

<!DOCTYPE HTML><HTMLLang= "ZH-CN"xmlns:th= "http://www.thymeleaf.org"><Head>  <MetaCharSet= "UTF-8">  <title>HeadDemo01</title></Head><Body><DivTh:replace= "~{header2:: Header}"></Div>headDemo01</Body></HTML>

Headdemo02.html

<!DOCTYPE HTML><HTMLLang= "ZH-CN"xmlns:th= "http://www.thymeleaf.org"><Head>  <MetaCharSet= "UTF-8">  <title>HeadDemo02</title></Head><Body><DivTh:replace= "~{header2:: Header}"></Div>headDemo02</Body></HTML>

Writing common modules in HTML using Thymeleaf

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.