Thymeleaf Java View Technology

Thymeleaf Java View Technology

This article tells about ThymeLeaf all tags

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

Library or namespace or import

2. <a th:href="@{/sp/save}">Update</a>

@{} here enter path or url

<a th:href="@{/}"></a> link

Example:

Java code:

@RequestMapping("/spec")//class level

@GetMapping("/delete")//method level

@RequestParam Integer id//Reading form data

UI code:

<a th:href="@{/spec/delete(id=${ob.id})}">Update</a>

3. @{}

url path

4. th:each

for each loop

<tr th:each="objectRef:${variableName}">

??????<td th:text="${objectRef.variableName}"></td>

??????<tr>

5. th:text

Display text in the browser

<div th:text="${attributeName}"></div>

6. ${}

To read variable data or to set variable data or EL used to display data at browser.

7. <form th:action=""></form>

method path or after submition goint to that url

example:

@PostMapping("/save")

<form th:action="@{/spec/save}"></form>

8. th:object

To read object data.

Link form with Object.

Example:

th:object="${}"

@ModelAttribute Employee objectRef

<form th:object="${ObjectRef}></form>

9. th:field

In thymeleaf * means linking

In form name="empName" id="empName"

th:field="*{variableName}"

*{variableName} it will call getter and setter methods.

Bi-Directional means Reading field data and Setting field or variable data

Replace name=" " id=" " with th:field

10. THML form:

<form action="" method="GET/POST"></form>

Uni-directional and static

11. ThymeLeaf form

Form connected to Object

<form th:action="@{/}" method="GET/POST" th:object="${objectRef}" ></form>

12. th:if

if condition

Example

if(10>12)

return true;

else return false;

th:if="${variablename!=null}

13. th:src

use th:src to localte static files like .js, .ts etc.

th:src="@{js/script.js}

img th:src for File Field data to Display

Example: <imag th:src="${}"/>

----------------------THE END------------------

要查看或添加评论,请登录

Sankar Karra的更多文章

  • Understanding Theory Concepts of Cursors, Indexes, and Views in Oracle(SQL/PLSQL)

    Understanding Theory Concepts of Cursors, Indexes, and Views in Oracle(SQL/PLSQL)

    Understanding Theory Concepts of Cursors, Indexes, and Views in Oracle(SQL/PLSQL): Cursors in Oracle (PL/SQL): 1…

  • STS/Eclipse Shortcuts

    STS/Eclipse Shortcuts

    Most important STS/Eclipse shortcuts: 1. Imports: ctrl+shift+o 2.

  • Spring Boot DevTools

    Spring Boot DevTools

    Spring Boot Devtools: Step1: 1. Spring Boot DevTools provides automatic restart functionality, allowing developers to…

  • Spring Boot Actuator and Admin Server, Client UI

    Spring Boot Actuator and Admin Server, Client UI

    Spring Boot Actuator Theory: Step1: a. Spring boot Actuator called a Production-ready end-points or production-ready…

  • Swagger UI or Test UI

    Swagger UI or Test UI

    Swagger UI(Test UI): 1. Swagger is an Open Source and it is Test UI.

  • HR Interview Story

    HR Interview Story

    HR Interview Story: A week ago, I sent a rejection email to a candidate who had interviewed for an open position…

  • Components in AEM

    Components in AEM

    Components in AEM: create a webpage by combining different components like a header, footer, text, image, video, or any…

  • Content Management System Tool

    Content Management System Tool

    In this article, I will discuss AEM[Adobe Experience Manager] AEM is a Content Management System Tool..

  • MongoDB

    MongoDB

    MongoDB: MongoDatabase Installation Process: 1. Download the MongoDB Zip file and extract it.

  • How do you choose between Hystrix and Resilience4j for Java web services?

    How do you choose between Hystrix and Resilience4j for Java web services?

    How do you choose between Hystrix and Resilience4j for Java web services? 1 Hystrix overview Hystrix is a library…

社区洞察

其他会员也浏览了