java.lang.NoSuchMethodException:java.util.ArrayList.get(java.lang.Long)

时间:2015-08-03 12:01:46

标签: list jsp el

这个EL表达式:

${ModelHelper:adults(dossier).get(0).creationDate}

引发以下异常:

javax.servlet.ServletException: org.glassfish.jersey.server.ContainerException: org.apache.jasper.JasperException: An exception occurred processing JSP page /WEB-INF/jspbo/users/dossier-list-paginee.jsp at line 52

49:                 <c:forEach var="dossier" items="${dossiers}">
50:                     <tr>
51:                         <td><a href="/lottery/bo/dossier/${dossier.id}/summary" class="capit">${dossier.id}</a></td>
52:                         <td data-title="'Création'">${ModelHelper:adults(dossier).get(0).creationDate}</td>
53:                         <td data-title="'MAJ'">${ModelHelper:adults(dossier).get(0).updateDate}</td>
54:                         <td data-title="'Principal'">
55:                             <a href="/lottery/bo/dossier/${dossier.id}/summary" class="capit">

java.lang.NoSuchMethodException: java.util.ArrayList.get(java.lang.Long)
java.lang.Class.getMethod(Class.java:1773)
javax.el.BeanELResolver.invoke(BeanELResolver.java:435)
org.apache.jasper.el.JasperELResolver.invoke(JasperELResolver.java:139)
org.apache.el.parser.AstValue.getValue(AstValue.java:173)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184)
org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:944)
org.apache.jsp.WEB_002dINF.jspbo.users.dossier_002dlist_002dpaginee_jsp._jspx_meth_c_005fforEach_005f0(dossier_002dlist_002dpaginee_jsp.java:400)
org.apache.jsp.WEB_002dINF.jspbo.users.dossier_002dlist_002dpaginee_jsp._jspService(dossier_002dlist_002dpaginee_jsp.java:276)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:439)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
com.franceservice.controllers.bo.DossierListController.getAllDossiers(DossierListController.java:258)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:483)
org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:151)
org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:172)
org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$VoidOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:136)
org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:104)
org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:384)
org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:342)
org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:101)
org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:303)
org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
org.glassfish.jersey.internal.Errors.process(Errors.java:315)
org.glassfish.jersey.internal.Errors.process(Errors.java:297)
org.glassfish.jersey.internal.Errors.process(Errors.java:267)
org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:316)
org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:286)
org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1073)
org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:377)
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:381)
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:344)
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:221)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

这是如何引起的?如何解决?

1 个答案:

答案 0 :(得分:1)

在表达式语言中,${0}等非十进制数字被隐式解释为Long

为了通过EL中的固定索引访问List项,您需要括号符[],而不是在List#get(int)上执行直接方法调用。

${ModelHelper:adults(dossier)[0].creationDate}

另见: