开发者

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?


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

<div class="${booleanExpr ? 'cssClass' : 'otherCssClass'}">
</div>



<c:if test='true'> 
  <c:set value="someclass" var="cssClass"></c:set>
</c:if> 
<div class="${cssClass}">
   <p>some other stuff...</p>
</div>


That works for me!

<div id="loginById" style="height:<% out.print(instanceClass.booleanMethod()? "250px": "150px");%>">
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜