JSTL

2014-12-26 4 views
0

에서/그것의 동등한 break 문을 수행 할 수 없습니다 내가 가지고있는 JSP로 내부 JSTL 코드의 조각 다음JSTL

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" 
    pageEncoding="ISO-8859-1"%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<script type="text/javascript" src="js/postprojectrequirement.js"></script> 
<link href="css/mystyle.css" type="text/css" rel="stylesheet" /> 
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> 
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 
<title>View Projects and Assign Employees</title> 
</head> 
<body> 

    <p align="right"> 
     <a href="http://localhost:9090/HCLRMS/home.jsp">Home</a>&nbsp;&nbsp;<a 
      href="http://localhost:9090/HCLRMS/logoutserv" 
      onclick='alert("You will be logged out now!")'>Logout</a> 
    </p> 
    <h1>View Projects and Assign Employees</h1> 

    <table align="center" border="1" > 

     <tr align="center"> 
      <td><h3>Projects</h3></td> 
      <td><h3>Requirement Details</h3></td> 
      <td><h3>Last Date</h3></td> 
     </tr> 
     <c:forEach var="rootBean" items="${vpaessbal}" > 
     <tr> 

       <br> 
       <br> 

       <td>${rootBean.beanprojname} <br> 
       <a href="">More Details</a></td> 
       <td> 
        <table border="1"> 
         <tr> 
          <th>Skill Set</th> 
          <th>Exp</th> 
          <th>No. of candidates</th> 
         </tr> 


         <c:forEach items="${rootBean.vpaerdclist}" var="subBean" varStatus="i"> 

           <tr> 

           <td>${subBean.skill}</td> 

           <td>${subBean.exp}</td> 

           <td>${subBean.ncand}</td> 

          </tr> 

         </c:forEach> 


        </table> 
       </td> 
       <td>${rootBean.beanlastdate}</td> 
      </tr> 

     </c:forEach> 
    </table> 



</body> 
</html> 

내가 같이 받고 있어요 누구의 출력 :

enter image description here

하지만 두 번째 행이 인쇄되는 것을 원하지 않습니다.

나는 봤는데 우리가 휴식을 쓸 수 없다는 것을 발견했다; 나는 JSTL에서 어떤 문장을 사용하고 싶지 않다.

+0

내가 혼동 될 수 있음을 기억해야하지만 (ViewProjAssEmpBean의 : vpaebal)에 대한'없는 것입니다 ... 휴식,'동등한 그냥'vpaebal [0]'을 표시하는 것, 즉 루프를 없애고 콜렉션의 첫 번째 요소를 표시하는 것인가? – fvu

+0

네, 맞습니다. 나는 내 질문을 편집했습니다! –

답변

0

c : forEach 태그에 iterator status 속성을 설정하십시오.

<c:forEach var="rootBean" items="${vpaessbal}" status="rowStatus">...</c:forEach> 

다음 현재 반복을 테스트하려면 rowStatus.count을 사용하십시오.

<c:if test="${rowStatus.count != 2}">..</c:if> 

그래서 당신은

<c:forEach var="rootBean" items="${vpaessbal}" status="rowStatus" > 
    <c:if test="${rowStatus.count != 2}"> 
      <tr> 

        <br> 
        <br> 

        <td>${rootBean.beanprojname} <br> 
        <a href="">More Details</a></td> 
        <td> 
         <table border="1"> 
          <tr> 
           <th>Skill Set</th> 
           <th>Exp</th> 
           <th>No. of candidates</th> 
          </tr> 


          <c:forEach items="${rootBean.vpaerdclist}" var="subBean" varStatus="i"> 

            <tr> 

            <td>${subBean.skill}</td> 

            <td>${subBean.exp}</td> 

            <td>${subBean.ncand}</td> 

           </tr> 

          </c:forEach> 


         </table> 
        </td> 
        <td>${rootBean.beanlastdate}</td> 
       </tr> 
       </c:if> 
      </c:forEach> 

count - starts with 1 
index - starts with 0.