html – th:href Thymleaf inserting Variable in Link Text-ThrowExceptions

Exception or error:

Hey Guys so I’m using Thymelaf in my HTML Email template. I’m creating a hyperlink that looks like this:

<a th:href="@{${username}__}">th:utext="${username}"</a>

The first part of the link works correctly and the username is correctly resolved by the template engine, but as you can see the link text doesn’t map at all. I want the link text to be exactly like the link itself. Does anyone know how this can bed done?

How to solve:

Solved with a simple <span> tag 🙂

<a th:href="@{${username}__}"><span th:text="''+${username}"></span></a></p>

Leave a Reply

Your email address will not be published. Required fields are marked *