2015-10-18 57 views
0

我有List<Members> ee = new ArrayList<>();在Servlet與Two Members Objects然後轉發eerequest.getSession().setAttribute("ee", ee);,但是當我嘗試打印它在JSP頁面。沒有顯示。列表不打印在Java JSP

這是我放在JSP頁面中的代碼。

<c:forEach items="${ee}" var="item"> 
    <c:out value="${item.ID}"/><br /> 
</c:forEach> 

這是會員類代碼。

public class Members { 
    private int ID; 
    private String name; 
    private String email; 
    public void setID(int id){ 
     this.ID=id; 
    } 
    public void setName(String name){ 
     this.name=name; 
    } 
    public void setEmail(String email){ 
     this.email=email; 
    } 
    public int getID(){ 
     return this.ID; 
    } 
    public String getName(){ 
     return this.name; 
    } 
    public String getEmail(){ 
     return this.email; 
    } 
} 

當我查看JSP頁面的頁面源代碼,我得到這個代碼:

<c:forEach items="[[email protected], [email protected]]" var="item"> 
    <c:out value=""/><br /> 
</c:forEach> 

回答

0

如果你看到在您的網頁源JSTL核心標籤,它只是意味着你的JSP不處理你的jstl標籤,因爲它應該。 您需要在jsp中導入jstl標籤並將jstl核心jar包含在web項目的類路徑中

<%@ taglib prefix="c" 
      uri="http://java.sun.com/jsp/jstl/core" %>