How can I test two attributes in jsp using c:if tag?

时间:2016-10-15 17:24:25

标签: jsp spring-mvc jstl

I want to check two attributes sent from server if they are empty or not in jsp using jstl tag c:if . For example I can use to check if error is empty : <c:if test="${not empty error}"></c:if> Like this , I want to check two objects error and logout at once to make a div if either of them is empty. How can I do this ?

1 个答案:

答案 0 :(得分:1)

使用AND运算符&amp;&amp;或OR运算符||

<c:if test="${not empty first && not empty second}"></c:if>
<c:if test="${not empty first || not empty second}"></c:if>

如果你想要它们是空的

<c:if test="${empty first && empty second}"></c:if>
<c:if test="${empty first || empty second}"></c:if>
相关问题