我的代码是这样的:
<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>
如果CCD_ 2不为空,则显示第二CCD_。当CCD_ 3不为空时显示第三个。当CCD_ 4和CCD_。类似的东西:
${lista} && ${command}
但是这个表达式会导致一个错误。有人知道怎么做吗?
更新
我尝试了:${lista && command}
和${lista and command}
,但没有解决我的问题(仍然发生错误)。
我认为@Andrew引用了正确的链接。如果您需要检查lista
为空,command
为空,只需检查即可。我不确定,但我想这个语法是不正确的-<div>
0
请改用th:if="${lista != null}"
。
因此,为了检查这两种情况:
th:if="${lista == null and command == null}"