🎓 Top 15 Udemy Courses (80-90% Discount): My Udemy Courses - Ramesh Fadatare — All my Udemy courses are real-time and project oriented courses.
▶️ Subscribe to My YouTube Channel (178K+ subscribers): Java Guides on YouTube
▶️ For AI, ChatGPT, Web, Tech, and Generative AI, subscribe to another channel: Ramesh Fadatare on YouTube
In this quick tutorial, we will take a look into Thymeleaf th:text attribute with examples.
Check out the complete Thymeleaf tutorials and examples at Thymeleaf Tutorial
Thymeleaf th:text Attribute
This attribute is responsible for displaying text that is evaluated from the expression inside it;
For example: To display a message:
<h2 th:text="${message}">Hello Good Morning!.</h2>The th:text attribute evaluates its value expression and sets the result as the body of the host tag, effectively replacing the “Hello Good Morning!” text we see in the code.
Example 1: Thymeleaf th:text Attribute with Variable Expressions
<p> Name: <strong th:text="${user.name}"></strong></p>
<p> Email: <strong th:text="${user.email}"></strong></p>
<p> Role: <strong th:text="${user.role}"></strong></p>
<p> Gender: <strong th:text="${user.gender}"></strong></p>Example 2: Thymeleaf th:text Attribute with Selection Expressions
<div th:object="${user}">
<p> Name: <strong th:text="*{name}"></strong></p>
<p> Email: <strong th:text="*{email}"></strong></p>
<p> Role: <strong th:text="*{role}"></strong></p>
<p> Gender: <strong th:text="*{gender}"></strong></p>
</div>Example 3: Thymeleaf th:text Attribute with Message Expressions
<h2 th:text="#{app.name}"></h2>
<h2 th:text="#{welcome.message}"></h2>Related Thymeleaf Tutorials and Examples
- Introducing Thymeleaf | Thymeleaf Template | Thymeleaf Template Engine
- Thymeleaf Example with Spring Boot
- How to Add CSS and JS to Thymeleaf
- Add Bootstrap CSS to Thymeleaf
- How to handle null values in Thymeleaf?
- How to Loop a List by Index in Thymeleaf
- Thymeleaf Array Example - Array Index, Array Iteration
- Thymeleaf Enums Example
- Thymeleaf If Else Condition Example
- Thymeleaf Switch Case Example
My Top and Bestseller Udemy Courses. The sale is going on with a 70 - 80% discount. The discount coupon has been added to each course below:
Build REST APIs with Spring Boot 4, Spring Security 7, and JWT
[NEW] Learn Apache Maven with IntelliJ IDEA and Java 25
ChatGPT + Generative AI + Prompt Engineering for Beginners
Spring 7 and Spring Boot 4 for Beginners (Includes 8 Projects)
Available in Udemy for Business
Building Real-Time REST APIs with Spring Boot - Blog App
Available in Udemy for Business
Building Microservices with Spring Boot and Spring Cloud
Available in Udemy for Business
Java Full-Stack Developer Course with Spring Boot and React JS
Available in Udemy for Business
Build 5 Spring Boot Projects with Java: Line-by-Line Coding
Testing Spring Boot Application with JUnit and Mockito
Available in Udemy for Business
Spring Boot Thymeleaf Real-Time Web Application - Blog App
Available in Udemy for Business
Master Spring Data JPA with Hibernate
Available in Udemy for Business
Spring Boot + Apache Kafka Course - The Practical Guide
Available in Udemy for Business
Comments
Post a Comment
Leave Comment