2013-08-21 3 views
0

작업 클래스에서 상태 메시지를받는 중입니다. 상태 메시지에 따라 두 개의 다른 이미지가 표시됩니다.사용 방법 If ..... Else JSP 페이지의 JSTl 태그 사용

상태 메시지가 "거부 됨"이면 JSP 페이지에 하나의 이미지가 표시됩니다. 다른 이미지를 표시하려고합니다.

+0

모든 단지에 대한 코드가있는 문은 그렇지위한 코드가 없다 "IF" 성명서. –

+0

이 [link] (http://www.datadisk.co.uk/html_docs/jsp/jsp_using_jstl.htm) –

+0

참조 - http://stackoverflow.com/questions/4587397/how-to-use-if -else-option-in-jstl? rq = 1 – Saurabh

답변

0

JSTL은 <c:choose>, <c:when><c:otherwise> 태그를 사용하여 JSP 내에 if-then-else 유형의 로직을 구현합니다. 기본 예제는 JSTL Core Choose Tag을 확인하십시오.

<c:choose> 
    <c:when test="${a boolean expr}"> 
     <!-- // do something --> 
    </c:when> 
    <c:when test="${another boolean expr}"> 
     <!-- // do something else --> 
    </c:when> 
    <c:otherwise> 
     <!-- // do this when nothing else is true --> 
    </c:otherwise> 
</c:choose> 
5

<c:choose> 
    <c:when test="${condition1}"> 
    ... 
    </c:when> 
    <c:when test="${condition2}"> 
    ... 
    </c:when> 
    <c:otherwise> 
    ... 
    </c:otherwise> 
</c:choose> 

에 따라 제공 자세한 내용은이 link

6

놀랍게도 JSTL, is documented을 참조 대신 그 JSTL의 JSTL에서와 같은 경우 다른 어떤 조건없는, 그리고 official tutorial있다 . Google이 가장 친한 친구입니다.

당신은 C를 찾고 : 선택, C를 : 때 C : 그렇지 않은 : 나는 많은 검색

<c:choose> 
    <c:when test="${status.message == 'Access Denied'}"> 
     ... 
    </c:when> 
    <c:otherwise> 
     ... 
    </c:otherwise> 
</c:choose>