目前我正在使用数据表来显示数据库中的一些项目。工作正常。
<h:dataTable border="1" value="#{overviewBean.loadContent }" var="item" first="0" >
<h:column id="column1">
<f:facet name="header">
<h:outputText value="#{messages.overviewSubscriptionID }"></h:outputText>
</f:facet>
<h:outputText value="#{item.subscriptionID }"></h:outputText>
</h:column>
<h:column id="column2">
<f:facet name="header">
<h:outputText value="#{messages.overviewCourseID}"></h:outputText>
</f:facet>
<h:outputText value="#{item.courseID }"></h:outputText>
</h:column>
...
<h:column id="column13">
<f:facet name="header">
<h:outputText value="#{messages.overviewDeleteItem }"></h:outputText>
</f:facet>
<h:commandButton action="#{overviewBean.delete}" value="X">
<f:param name="delete" value="#{item.courseID}"></f:param>
</h:commandButton>
</h:column>
</h:dataTable>
每当现在param-tag存在时,页面都不会加载。这是抛出的异常:
/overview.jsp(15,1) '#{overviewBean.loadContent }' java.lang.IllegalArgumentException
Caused by:
java.lang.IllegalArgumentException - java.lang.IllegalArgumentException
<小时/> 修改:因为已请求,我添加了整个堆栈跟踪(如生成的页面所示):
org.apache.jasper.el.JspELException: /overview.jsp(15,1) '#{overviewBean.loadContent }' java.lang.IllegalArgumentException
at org.apache.jasper.el.JspValueExpression.getValue(JspValueExpression.java:107)
at javax.faces.component.UIData.getValue(UIData.java:1142)
at javax.faces.component.UIData.createDataModel(UIData.java:1082)
at javax.faces.component.UIData.getDataModel(UIData.java:1056)
at javax.faces.component.UIData.getRowCount(UIData.java:449)
at org.apache.myfaces.shared_impl.renderkit.html.HtmlTableRendererBase.encodeInnerHtml(HtmlTableRendererBase.java:234)
at org.apache.myfaces.shared_impl.renderkit.html.HtmlTableRendererBase.encodeChildren(HtmlTableRendererBase.java:143)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:627)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:250)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:257)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:257)
at org.apache.myfaces.application.jsp.JspViewHandlerImpl.actuallyRenderView(JspViewHandlerImpl.java:427)
at org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:383)
at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:41)
at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:140)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:187)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:662)
Caused by: javax.faces.el.EvaluationException: java.lang.IllegalArgumentException
at org.apache.myfaces.el.VariableResolverImpl.resolveVariable(VariableResolverImpl.java:80)
at org.apache.myfaces.el.convert.VariableResolverToELResolver.getValue(VariableResolverToELResolver.java:95)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
at org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:142)
at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:68)
at org.apache.el.parser.AstValue.getValue(AstValue.java:112)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
at org.apache.jasper.el.JspValueExpression.getValue(JspValueExpression.java:101)
... 27 more
Caused by: javax.el.ELException: java.lang.IllegalArgumentException
at javax.el.BeanELResolver.setValue(BeanELResolver.java:116)
at javax.el.CompositeELResolver.setValue(CompositeELResolver.java:69)
at org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver.setValue(FacesCompositeELResolver.java:182)
at org.apache.myfaces.config.ManagedBeanBuilder.initializeProperties(ManagedBeanBuilder.java:268)
at org.apache.myfaces.config.ManagedBeanBuilder.buildManagedBean(ManagedBeanBuilder.java:92)
at org.apache.myfaces.el.unified.resolver.ManagedBeanResolver.createManagedBean(ManagedBeanResolver.java:198)
at org.apache.myfaces.el.unified.resolver.ManagedBeanResolver.getValue(ManagedBeanResolver.java:164)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
at org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:142)
at org.apache.myfaces.el.VariableResolverImpl.resolveVariable(VariableResolverImpl.java:65)
... 34 more
Caused by: java.lang.IllegalArgumentException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at javax.el.BeanELResolver.setValue(BeanELResolver.java:108)
... 43 more
<小时/> 修改2:以下是指向实际生成的网页的链接:index_jsp.html
有什么想法吗? bean已注册,否则正常工作。删除方法也存在。 (列id也是正确的)
答案 0 :(得分:1)
基于堆栈跟踪,您正在使用MyFaces。这可能是特定于MyFaces的,我从未在Mojarra上看过这个,我已经使用了多年。
至少,在f:param
中使用h:commandButton
无论如何都无法使用JSF 1.x.它仅适用于h:commandLink
。另一方面,您应该将数据表的值包装在DataModel
中,以便您可以获得按下按钮的行。或者,如果您使用的是JSF 1.2,则还可以使用f:setPropertyActionListener
。您可以在this answer中找到示例。