Thymeleaf Interactive Tutorial

Exercise 16: literal substitutions

This exercise introduces three ways of doing String concatenation in Thymeleaf.
First, concatenating from the Using Thymeleaf manual.
Second, preprocessing from the Using Thymeleaf manual.
Third, literal substitutions from the What's New article.

  1. There is a String variable with name customerName in the context model that we want to display instead of the text Peter inside the three span elements.
  2. Substitute it using three diferent syntaxes:
    1. String concatenation
    2. Preprocessing
    3. Literal substitutions
  3. 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