2013-11-25 3 views
0

안녕하세요 저는 jstl에서 두 정수 값을 비교하려고합니다. 결과가 false 인 경우에도 false를 반환합니다.JSTL의 정수 값을 비교하는 방법

String numofcell=(String)request.getAttribute("numberofcell"); 
int noc = Integer.parseInt(numofcell); 
int num = 4; 

<c:choose> 
    <c:when test = "${noc eq num}"> 
     <%=noc%> 
     hiiiiiiiiiiiii 
    </c:when> 
    <c:otherwise> 
     <%=noc%> 
     HELLLOOOOOOO 
    </c:otherwise> 
</c:choose> 

출력은 여기

내 코드입니다 : 4 HELLLOOOOOOO

답변

1

당신이 놓친 EL 기호 ${}, 시도,

<c:set var="noc" value="<%=noc%>"/>  
    <c:set var="num" value="<%=num%>"/> 


    ..... 
    <c:when test = "${noc eq num}"> 
    ......... 
+0

thanx masud 나는 변수를 설정하는 것을 잊어 버립니다. – user2142786

0
String numofcell="4"; 
int noc = Integer.parseInt(numofcell); 
int num = 4; 

<c:choose> 
    <c:when test = "noc eq num"> 
     <%=noc%> 
     hiiiiiiiiiiiii 
    </c:when> 
    <c:otherwise> 
     <%=noc%> 
     HELLLOOOOOOO 
    </c:otherwise> 
</c:choose> 

를이 코드주는 출력 : 4 hiiiiiiiiiiiii 4 헬름 우노

0
String numofcell="4"; 
int noc = Integer.parseInt(numofcell); 
int num = 4; 
pageContext.setAttribute("noc",noc); 
pageContext.setAttribute("num",num); 

<c:choose> 
    <c:when test = "${noc eq num}"> 
     <%=noc%> 
     hiiiiiiiiiiiii 
    </c:when> 
    <c:otherwise> 
     <%=noc%> 
     HELLLOOOOOOO 
    </c:otherwise> 
</c:choose>