Right at the beginning of Thymeleaf documentation about standard url syntax there are two examples, but there is nothing said about the difference between them:
<a th:href="@{http://www.thymeleaf/documentation.html}">
<a href="http://www.thymeleaf/documentation.html">
Is there a difference between the two? If no, what is the use of the first one?
In that specific case, there is no difference.
<a th:href="@{http://www.thymeleaf/documentation.html}">
will produce exactly
<a href="http://www.thymeleaf/documentation.html">
It's only there to because those sections are listing the different types of urls that url expressions work with (absolute, context relative, server relative and protocol relative). That being said, there are reasons you might use it... such as including an id in an absolute url. Something like:
<th:block th:with="id=${42774564}">
<a th:href="@{https://stackoverflow.com/questions/{id}(id=${id})}">Stack Overflow</a>
</th:block>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With