是否可以在 JSTL 中做这样的事情:
<div class="firstclass<c:if test='true'> someclass</c:if>">
<p>some other stuff...</p>
</div>
有没有办法让它工作,或者有没有更好的方法通过查看 JSTL-if 语句来添加一个类?
也可以像这样直接使用 EL 表达式:
<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>
这对我行得通!
<div id="loginById" style="height:<% out.print(instanceClass.booleanMethod()? "250px": "150px");%>">