存储值从arraylist获取到int变量

时间:2013-09-18 14:14:51

标签: jsp

    <%-- JSTL foreach tag example to loop an array in jsp --%>
    <c:forEach var="window" items="${listOFSchools}">
    <c:out value='${window.school_id }'/>
    <%

    SchoolDisplayService CDS = new SchoolDisplayService();

   List<Schooltable> list = CDS.getSchools(window.school_id );

    %>

我想将从数组列表“listOFSchools”中获取的school_id传递给方法getSchools()。我怎么能这样做?

1 个答案:

答案 0 :(得分:0)

您可以使用Tag set <c:set />设置school_id

<c:forEach var="window" items="${listOFSchools}">
 <c:set var="schoolId" value="${window.school_id}" />

用于访问scriptlet JSTL内的see my anwer.变量schoolId 在你的情况下,

<%
    SchoolDisplayService CDS = new SchoolDisplayService();

    int schId = (Integer)pageContext.getAttribute("schoolId");

    List<Schooltable> list = CDS.getSchools(schId);
%>