2013-04-10 87 views
-1

我有jsp頁面給出,正在轉發一個ArrayList Arrangor是bean,就像我用構造函數和getMethods做的類一樣。但是當我嘗試在jsp頁面輸出它們時。但是,螢火蟲發現實例正在發送的所有數據。但<:c forEach>標籤似乎直接關閉它自身。有誰知道爲什麼。JSP,<c:forEach>自己關閉到早

編輯:抱歉,關於壞句子。 EDIT2看來似乎中間句話得到了去除

<table border="1"> 
<c:forEach items="${arrangorer}" var="arr"> 
<tr> 
    <th>Id</th> 
    <th>Namn</th> 
    <th>Telefon Nummer</th> 
    <th>Email</th> 
</tr> 




<tr> 
<td> <c:out value="${arr.id}"></td> 
<td> <c:out value="${arr.name}"></td> 
<td> ${arr.getNumber()}</td> 
<td> ${arr.getEmail()} </td> 
</tr> 
</c:forEach> 

</table> 

然後我包括在我的索引頁的abouve JSP片段。

<%@page language="java" contentType="text/html"%> 
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 
<%@page import="java.util.ArrayList" %> 


    <div id="include_show"> 
     <jsp:include page="WEB-INF/show.jsp" /> 
    </div> 

我得到以下螢火蟲輸出:

<div id="include_show"> 
    <c:foreach var="arr" items="[[email protected],[email protected]@239d58, [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]]"> 
</c:foreach> 
<table border="1"> 
<tbody> 
<tr> 
<th>Id</th> 
<th>Namn</th> 
<th>Telefon Nummer</th> 
<th>Email</th> 
</tr> 
<tr> 
    <td><c:out value=""></c:out></td> 
    <td><c:out value=""> </c:out></td> 
    <td> </td> 
    <td> </td> 
</tr> 
</tbody> 

+0

請給予downvote時留下評論。否則如何知道糾正錯誤 – PSR 2013-04-10 13:10:44

+0

@PSR可能是downvoter不知道答案.. lolz – 2013-04-10 13:24:26

+0

爲什麼taglib聲明在JSP的末尾,而不是在一開始,它應該在哪裏? – 2013-04-10 13:29:12

回答

0

的標籤庫declaratiion必須的使用的taglib頂部每隔 JSP。所以它也必須出現在show.jsp的頂部。

請注意,您的網頁上還存在其他錯誤:例如未關閉<c:out>標記。

+0

右在錢上謝謝。只是一個非正式的問題,我可以省略額外的包括,如果我使用.jspf擴展而不是 – Filip 2013-04-10 14:06:00

+0

如果你靜態地包含它(使用'<%@ include file =「...」%>')而不是動態的包括它。而'.jspf'擴展名只能用於靜態包含的JSP片段(或任何JSP片段的新名稱) – 2013-04-10 14:36:37