【发布时间】:2010-12-09 01:13:46
【问题描述】:
是否可以在 JSTL 中做这样的事情:
<div class="firstclass<c:if test='true'> someclass</c:if>">
<p>some other stuff...</p>
</div>
有没有办法让它工作,或者有没有更好的方法通过查看 JSTL-if 语句来添加一个类?
【问题讨论】:
是否可以在 JSTL 中做这样的事情:
<div class="firstclass<c:if test='true'> someclass</c:if>">
<p>some other stuff...</p>
</div>
有没有办法让它工作,或者有没有更好的方法通过查看 JSTL-if 语句来添加一个类?
【问题讨论】:
<c:if test='true'>
<c:set value="someclass" var="cssClass"></c:set>
</c:if>
<div class="${cssClass}">
<p>some other stuff...</p>
</div>
【讨论】:
也可以像这样直接使用 EL 表达式:
<div class="${booleanExpr ? 'cssClass' : 'otherCssClass'}">
</div>
【讨论】:
这对我有用!
<div id="loginById" style="height:<% out.print(instanceClass.booleanMethod()? "250px": "150px");%>">
【讨论】: