Check if parameter exists in Expression Language

Borut Flis picture Borut Flis · Jun 7, 2012 · Viewed 72.8k times · Source
<c:if test="${param.username}" >
</c:if>

How do I check if param.username exists??

Answer

adarshr picture adarshr · Jun 7, 2012

Use the not empty check.

<c:if test="${not empty param.username}" >
</c:if>

Edit: If you have a parameter of the form ?username (no value), it is safer to use ${param.username ne null}