嗨,我试图遍历会话中的对象列表。我再次使用 jstl 遍历会话中的每个对象。这是jsp代码
<c:forEach items="${sessionScope}" var="item">
<b>${item.key}</b>
<table border=1>
<c:forEach items="${item.nodes}" var="node">
<tr>
<td>${node.link}</td>
<td>${node.title}</td>
<td>${node.description}</td>
</tr>
</c:forEach>
</table>
</c:forEach>
这是节点类
public class Nde {
private String title;
private String link;
private String description;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getLink() {
return link;
}
public void setLink(String link) {
this.link = link;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}
以及具有 Nde 类对象列表的 PersonalData 类。
public class PersonalData {
private List<Nde> nodes;
private static int count=0;
private String s;
public List<Nde> getNodes() {
return nodes;
}
public String getS() {
return s;
}
public void setS(String s) {
this.s = s;
}
public void setNodes(List<Nde> nodes) {
this.nodes = nodes;
}
public PersonalData() {
super();
count++;
nodes = new ArrayList<Nde>();
}
public static int getCount() {
return count;
}
}
在遍历项目时,我收到以下异常
che.jasper.el.JspPropertyNotFoundException: /WEB-INF/views/display.jsp(17,0) '${item.nodes}' Property 'nodes' not found on type javax.servlet.jsp.el.ImplicitObjectELResolver$ScopeMap$ScopeEntry
org.apache.jasper.el.JspValueExpression.getValue(JspValueExpression.java:109)
org.apache.jsp.WEB_002dINF.views.display_jsp._jspx_meth_c_005fforEach_005f1(display_jsp.java:155)
org.apache.jsp.WEB_002dINF.views.display_jsp._jspx_meth_c_005fforEach_005f0(display_jsp.java:122)
org.apache.jsp.WEB_002dINF.views.display_jsp._jspService(display_jsp.java:78)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:262)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1180)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:950)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
为什么找不到节点属性?