Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSTL if-statement inside HTML-attribute

is it possible to do something like this in JSTL:

<div class="firstclass<c:if test='true'> someclass</c:if>">    <p>some other stuff...</p> </div> 

Is there any way to get this to work, or is there a better way to add a class by looking at a JSTL-if-statement?

like image 467
Mickel Avatar asked Oct 22 '09 10:10

Mickel


1 Answers

It's also possible to use an EL expression directly like this:

<div class="${booleanExpr ? 'cssClass' : 'otherCssClass'}"> </div> 
like image 165
runfa Avatar answered Sep 18 '22 19:09

runfa