본문 바로가기
카테고리 없음

JSTL When(IF), NE, EMPTY C 태그 정리

by 달남 2019. 10. 15.

기본 문법

IF 문 대신 When 문법을 사용합니다.

<c:choose>
<c:when test="${변수 연산자 변수}">

</c:when>
<c:otherwise>

</c:otherwise>
</c:choose>

= 대신 eq 를 사용합니다.

<c:choose>
<c:when test="${name eq '이름'}">

</c:when>
<c:otherwise>

</c:otherwise>
</c:choose>

not equal ( != ) 은 ne 입니다.

<c:choose>
<c:when test="${name ne '이름'}">

</c:when>
<c:otherwise>

</c:otherwise>
</c:choose>

 

empty 명령어로 null 체크가 가능합니다.

<c:choose>
<c:when test="${empty name}">

</c:when>
<c:otherwise>

</c:otherwise>
</c:choose>

많이 사용하는 not empty 입니다.

<c:choose>
<c:when test="${not empty name}">

</c:when>
<c:otherwise>

</c:otherwise>
</c:choose>

 

댓글