Book Image

Mastering Spring Application Development

By : Anjana Mankale
Book Image

Mastering Spring Application Development

By: Anjana Mankale

Overview of this book

Table of Contents (19 chapters)
Mastering Spring Application Development
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Thymeleaf attributes


Let's look at some of the basic attributes that Thymeleaf provides for designing a page. We shall also look at the how it interacts with Java object and loops. Thymeleaf uses a lot of attributes.

  • To display a message:

    <p th:text="#{msg.greet}">Helloo Good Morning!</p>
  • To display a loop, we have th:each:

    <li th:each="product : ${products}" th:text="${product.title}">XYZLLDD</li>
  • Now, lets look at a form submit action:

    <form th:action="@{/buyBook}">
  • If we have to button submit, then add:

    <input type="button" th:value="#{form.submit}" />