我在按索引从列表中获取对象时遇到问题:
我的jsp:
<c:choose>
<c:when test="${empty findAttributes}">
<h1 align="center">Attributes are empty</h1>
</c:when>
<c:otherwise>
<table align="center" border="1" id="resultTable">
<c:forEach items="${findAttributes}" var="findAttributesVar" varStatus="status">
<tr>
<td align="center">${findAttributesVar.status.index.formDescriptionList.status.status.institutions.nameOfInstitution}</td>
<td align="center">${findAttributesVar.status.index.formDescriptionList.status.status.institutionType.typeOfInstitution}</td>
<td align="center">${findAttributesVar.status.index.formDescriptionList.daySchedule}</td>
<td align="center">${findAttributesVar.status.index.formDescriptionList.workScheduale}</td>
</tr>
</c:forEach>
</table>
</c:otherwise>
</c:choose>
我正在获取属性作为列表findAttributes
并尝试通过 jsp 页面中的索引获取对象,类似于 java 代码,例如:
attributesList.get(i).getFormDescriptionList().get(i).getInstitutions().getNameOfInstitution());
attributesList.get(i).getFormDescriptionList().get(i).getInstitutionType().getTypeOfInstitution();
attributesList.get(i).getParticularDate().toString());
attributesList.get(i).getFormDescriptionList().get(i).getDaySchedule());
attributesList.get(i).getFormDescriptionList().get(i).getWorkScheduale());
我的堆栈跟踪错误:
Jul 26, 2013 4:57:18 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [appServlet] in context with path [/web] threw exception [An exception occurred processing JSP page /WEB-INF/views/search.jsp at line 141
138: <tr>
139:
140: <td align="center">${findAttributesVar.particularDate}</td>
141: <td align="center">${findAttributesVar.status.index.formDescriptionList.daySchedule}</td>
142: <td align="center">${findAttributesVar.status.index.formDescriptionList.workScheduale}</td>
143: <td align="center">${findAttributesVar.status.index.formDescriptionList.rotation}</td>
144: <td align="center">${findAttributesVar.status.index.formDescriptionList.numberOfKids}</td>
Stacktrace:] with root cause
javax.el.PropertyNotFoundException: Property 'status' not found on type edu.demidov.dto.FormDate
at javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:223)
at javax.el.BeanELResolver$BeanProperties.access$400(BeanELResolver.java:200)
at javax.el.BeanELResolver.property(BeanELResolver.java:311)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:85)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:67)
at org.apache.el.parser.AstValue.getValue(AstValue.java:169)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:189)
at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:985)
at org.apache.jsp.WEB_002dINF.views.search_jsp._jspx_meth_c_005fforEach_005f3(search_jsp.java:1157)
at org.apache.jsp.WEB_002dINF.views.search_jsp._jspx_meth_c_005fotherwise_005f0(search_jsp.java:790)
at org.apache.jsp.WEB_002dINF.views.search_jsp._jspx_meth_c_005fchoose_005f0(search_jsp.java:639)
at org.apache.jsp.WEB_002dINF.views.search_jsp._jspService(search_jsp.java:222)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:471)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:263)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1208)
at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:992)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:939)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
我的 FormDate 实体:
包edu.demidov.dto;
@Entity
@Table(name="FORM_DATE")
public class FormDate implements Serializable{
private static final long serialVersionUID = -6727012506326164775L;
private int dateId;
@Id
@GeneratedValue(strategy= IDENTITY)
@Column(name="DATE_ID")
public int getDateId() {
return dateId;
}
public void setDateId(int dateId) {
this.dateId = dateId;
}
private int version;
@Version
@Column(name="VERSION")
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
private Date particularDate;
@Column(name="PARTICULAR_DATE")
@DateTimeFormat(pattern="yyyy-MM-dd")
@Temporal(TemporalType.DATE)
public Date getParticularDate() {
return particularDate;
}
public void setParticularDate(Date particularDate) {
this.particularDate = particularDate;
}
private List<FormDescription> formDescriptionList = new ArrayList<FormDescription>();
@OneToMany(mappedBy="formDate")
@Cascade(CascadeType.ALL)
public List<FormDescription> getFormDescriptionList() {
return formDescriptionList;
}
public void setFormDescriptionList(List<FormDescription> formDescriptionList) {
this.formDescriptionList = formDescriptionList;
}
}
c:forEach
它是如何使用嵌套c:forEach
在属性中的两个对象创建表的:
-=TABLE=-
|header1|header2|header3|
-------------------------
|value1| Value1 |value1 |
-------------------------
|value2| Value2 |value2 |
-------------------------
|value1| Value1 |value1 |
-------------------------
|value2| Value2 |value2 |