Thymeleaf Interactive Tutorial

Exercise 19: conditional th:remove

This exercise introduces the Conditional th:remove from the What's New article.

  1. You have a context variable called customerList containing a List of Customer objects.
  2. The Customer class has a field called personalWebsite which contains the customer personal website URL, or null if the customer does not have a personal website.
  3. Use the new conditional th:remove to add a link to the customer personal website in the displayed first names and last names if the customer has a website. If the customer does not have a website, simply print their first and last names.
  4. You can check the proposed solution by pressing the Show solution button () above the code editor.

Welcome to the Thymeleaf Interactive Tutorial. Thymeleaf version used in this tutorial is 2.1.5.RELEASE.

This interactive tutorial has been created by the Thymeleaf Team using The Thymeleaf Template Engine and other great open source tools like:

The tutorial is gracefully hosted at the Heroku Cloud Platform

Icons used in this app, except Thymeleaf logo, are created by Mark James

You can get the source code of this tutorial at GitHub.

You can find much more documentation on Thymeleaf at the Thymeleaf website.

For any questions or help, you can use the user forum.

Source code

Static view

Generated source

Dynamic view