728x90
728x90
- <c:choose></c:choose>
<c:choose>
<c:when test="${title eq 'APPLE'}">애플</c:when>
<c:when test="${title eq 'SAMSUNG'}">삼성</c:when>
<c:otherwise>기타</c:otherwise>
</c:choose>
- <c:if></c:if>
else 구문이 없습니다. else를 사용하고싶으신분들은 비슷한 choose를 사용하시면 됩니다.
<c:if test="${title eq 'APPLE'">
<p>애플</p>
</c:if>
<c:if test="${title eq 'SAMSUNG'">
<p>삼성</p>
</c:if>
- 논리연산자
- and(&&) : 모두 true 일때 true
<c:if test="${a>b and c>d}"></c:if>
<c:if test="${a>b && c>d}"></c:if>
- or(||) : 둘 중 하나라도 true 일때 ture
<c:if test="${a>b or c>d}"></c:if>
<c:if test="${a>b || c>d}"></c:if>
- not(!) : 논리를 반전
<c:if test="${not a}"></c:if>
<c:if test="${!a}"></c:if>
- 비교연산자
- eq(==) : 값이 같으면 참입니다.
<c:if test="${title == 'APPLE'}">애플</c:if>
<c:if test="${title eq 'APPLE'}">애플</c:if>
<c:if test="${title == null}">-</c:if>
<c:if test="${title eq null}">-</c:if>
<c:if test="${number == 5}">5</c:if>
<c:if test="${number eq 5}">5</c:if>
- ne(!=) : 값이 다르면 참입니다.
<c:if test="${title != 'APPLE'}">삼성</c:if>
<c:if test="${title ne 'APPLE'}">삼성</c:if>
<c:if test="${title != null}">-</c:if>
<c:if test="${title ne null}">-</c:if>
<c:if test="${number != 5}">${number}</c:if>
<c:if test="${number ne 5}">${number}</c:if>
- empty: 배열이 비어있거나 null 또는 빈 문자열일 경우 true
<c:if test="${empty title}">제목없음</c:if>
- not empty: 배열에 값이 있거나 문자열이 있을 경우 true
<c:if test="${not empty title}">${title}</c:if>
728x90
300x250