Render HTML conditionally in Spring MVC

java, spring, spring-mvc

Solution

Plain old JSTL to your rescue!

The beauty of Spring MVC is that it doesn't add tons of redundant tag libraries unlike other frameworks. You can always rely on JSTL for such checks which is part of the JSP spec now.

<c:if test="${not empty someList}">

</c:if>

Problem

Is there any tag which lets to render the HTML blocks conditionally. For e.g.: Struts has: ``` <logic:present name="someForm" property="someProperty"> //Code block </logic:present> ``` For e.g.: JSF has: ``` <h:panelGrid rendered="#{not empty someList}"> //Some code block </h:panelGrid> ``` Is there anything like that in spring MVC?

Original source