2015-10-18 58 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" %>