【发布时间】:2016-11-26 20:26:09
【问题描述】:
我的代码是这样的:
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
<h1 class="page-header" th:utext="#{dashboard}">Dashboard</h1>
</div>
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main" th:if="${lista}">
<h1 class="page-header" th:text="#{__${name}__}"></h1>
</div>
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main" th:if="${command}">
<h1 class="page-header"><th:block th:utext="#{__${action}__}"/> <th:block th:utext="#{__${name}__}"/></h1>
</div>
如果lista 不为空,则显示第二个<div> 块。当command 不为空时显示第三个。当lista 和command 都为空时,应显示第一个。类似的东西:
${lista} && ${command}
但是这个表达式会导致错误。有人知道怎么做吗?
更新
我尝试:${lista && command} 和 ${lista and command} 但没有解决我的问题(仍然发生错误)。
【问题讨论】: