How can I properly check if the URL contains request parameters in thymeleaf?
thymeleaf
Solution
This is tricky. In the documentation you are encouraged to use:
${param.containsKey('foo')}
But it doesn't work and when you look at the source of this class it's suddenly clear:
@Override
public boolean containsKey(final Object key) {
return true;
}
I end up with:
${param.keySet().contains('foo')}
Problem
This is the URL I use for signin page without any request parameters. ``` http://localhost:8080/signin ``` This is the URL for signin page with bad credentials error, ``` http://localhost:8080/signin?param.error=bad_credentials ``` Now I check for `param.error` like below, ``` <div class="error" th:if="${(param.error != null) and (param.error[0] == 'bad_credentials')}"> ``` When I load the signin page I get a SpringEL exception, ``` Exception evaluating SpringEL expression: "(param.error != null) and (param.error[0] == 'bad_credentials')" ``` I think since there are no request parameters when I load the signin page it cant find `param.error`. How can I properly check if the URL contains request parameters?