Thymeleaf: how to get URL attribute value

Maxim Kolesnikov picture Maxim Kolesnikov · Jan 25, 2013 · Viewed 30.8k times · Source

I can't find any solution for getting attribute from URL using Thymeleaf. For example, for URL:

somesite.com/login?error=true

I need to get "error" attribute value. Also I'm using SpringMVC, if it could be helpful.

Answer

Maxim Kolesnikov picture Maxim Kolesnikov · Jan 25, 2013

After some investigation I found that it was Spring EL issue actually. So complete answer with null checking is:

<div id="errors" th:if="${(param.error != null) and (param.error[0] == 'true')}">
    Input is incorrect
</div>