我有一个豆类:
public class Event{
private Customer customer
private String stringdate
public Event(){}
/*all getters and setters here*/
}
public class Customer{
private int custId
private String custname
public Customer(){}
/*all getters and setters here*/
}
有没有办法使用 JSTL 在 jsp 页面上显示内容?
编辑: eventsView 是从 servlet 传入的事件列表。当它是一个 int 字段时,我可以显示“cust”变量,但是当我将它更改为自定义类 Customer 时,我无法显示它,因为我得到下面的异常。
<c:forEach items="${ eventsView }" var="events" varStatus="index">
<tr>
<td>${ index.count }</td>
<td>${ events.customer.custid }</td>
<td>${ events.stringdate }</td>
</tr>
</c:forEach>
谢谢
堆栈跟踪:
SEVERE: Servlet.service() for servlet [jsp] in context with path [/CaspinolCustTest] threw exception [An exception occurred processing JSP page /event.jsp at line 32
29: <c:forEach items="${ eventsView }" var="events" varStatus="index">
30: <tr>
31: <td>${ index.count }</td>
32: <td>${ events.customer.custId }</td>
33: <td>${ events.stringdate }</td>
Stacktrace:] with root cause
java.lang.NumberFormatException: For input string: "customer"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:481)
at java.lang.Integer.parseInt(Integer.java:514)
at javax.el.ArrayELResolver.coerce(ArrayELResolver.java:166)
at javax.el.ArrayELResolver.getValue(ArrayELResolver.java:46)
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.event_jsp._jspx_meth_c_005fforEach_005f0(event_jsp.java:148)
at org.apache.jsp.event_jsp._jspService(event_jsp.java:100)
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:432)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
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:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
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:679)