HTML属性内のJSTL ifステートメント
質問
JSTLで次のようなことを行うことは可能ですか:
<div class="firstclass<c:if test='true'> someclass</c:if>">
<p>some other stuff...</p>
</div>
これを機能させる方法はありますか、それともJSTL-if-statementを見てクラスを追加するより良い方法がありますか?
解決
次のように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");%>">
所属していません StackOverflow