2013-02-12 54 views
0

我有Request scopeArraylist在駐留在從Jsp頁面ArrayList類檢查的屬性值,它包含了所有Students對象.. 我在快樂JSP page如何使用<c:if>

class Student 
    { 

    int sno; 
    String name; 
    String type; // here type can be either R or D 
    . 
    . 
    . 
    } 

顯示的數據,而我'顯示Student obj我想查看的數據student type if type=D然後我想添加<select>框 如何做到這一點???

我使用struts 1.3JDBC

我的代碼是

<logic:iterate id="student" name="allstudents" scope="request"> 

    <bean:write name="student" property="sno" format="#"/><br> 
    <bean:write name="student" property="name" /><br> 
    <bean:write name="student" property="type" /><br> 


    // here i want to display <select> if type =D 
    . 
    . 
    . 
</logic:iterate> 

請幫我

在此先感謝

回答

1

請你幫個忙,並學習JSTL。一旦完成後,使用<c:forEach><c:out><fmt:formatNumber><c:if>標籤:

<c:forEach var="student" items="${allstudents}"> 

    <fmt:formatNumber value="${student.sno}" pattern="#"/> 
    <c:out value="${student.name}"/> 
    <c:out value="${student.type}"/> 
    <c:if test="${student.type == 'D'}> 
     ... 
    </c:if> 

</c:forEach> 
+0

Thanq JB Nizet爲您的寶貴答案... – Clarence 2013-02-12 08:54:59

0
i tried like this this is working fine... 
thank you JB Nizet.... 

<logic:iterate id="student" name="allstudents" scope="request"> 

     <bean:write name="student" property="sno" format="#"/><br> 
     <bean:write name="student" property="name" /><br> 
     <bean:write name="student" property="type" /><br> 


     <c:if test="${student.type == 'D'}> 
     ...... 
     </c:if> 

    </logic:iterate>