0

    <%-- 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()。我怎样才能做到这一点?

4

1 回答 1

0

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

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

要访问scriptlet中的JSTL变量,请参阅我的回答。 在你的情况下, schoolId

<%
    SchoolDisplayService CDS = new SchoolDisplayService();

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

    List<Schooltable> list = CDS.getSchools(schId);
%>
于 2013-11-18T09:42:34.347 回答