0

我遇到了问题,我正在使用 primefaces 的组件数据表来显示产品列表:

<h:form id="id_form">

        <p:dataTable var="prod" value="#{produitBean.listeProduit}"  widgetVar="grilleProduit">
            <f:facet name="header">
                Liste des produits
            </f:facet>

            **<p:column>
                <f:facet name="header">
                    Aperçu
                </f:facet>
                <p:graphicImage value="#{prod.urlImg}" />
            </p:column>**
            <p:column >
                <f:facet name="header">
                    Nom 
                </f:facet>
                <h:outputText value="#{prod.libelle}" />
            </p:column>

            <p:column >
                <f:facet name="header">
                    Déails
                </f:facet>
                <h:outputText value="#{prod.details}" />
            </p:column>


          </p:dataTable>


    </h:form>

问题出在产品的图像上,当我为图像添加一列时,我遇到了 java.lang.StringIndexOutOfBoundsException:字符串索引超出范围:0。当我删除它时它可以工作。我不明白这个错误的含义。这是堆栈跟踪:

java.lang.StringIndexOutOfBoundsException: String index out of range: 0
at java.lang.String.charAt(String.java:658)
at com.sun.faces.application.view.MultiViewHandler.getResourceURL(MultiViewHandler.java:341)
at javax.faces.application.ViewHandlerWrapper.getResourceURL(ViewHandlerWrapper.java:244)
at org.jboss.weld.jsf.ConversationAwareViewHandler.getResourceURL(ConversationAwareViewHandler.java:143)
at org.primefaces.renderkit.CoreRenderer.getResourceURL(CoreRenderer.java:76)
at org.primefaces.component.graphicimage.GraphicImageRenderer.getImageSrc(GraphicImageRenderer.java:84)
at org.primefaces.component.graphicimage.GraphicImageRenderer.encodeEnd(GraphicImageRenderer.java:45)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1764)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
at org.primefaces.component.datatable.DataTableRenderer.encodeCell(DataTableRenderer.java:808)
at org.primefaces.component.datatable.DataTableRenderer.encodeRow(DataTableRenderer.java:773)
at org.primefaces.component.datatable.DataTableRenderer.encodeTbody(DataTableRenderer.java:651)
at org.primefaces.component.datatable.DataTableRenderer.encodeRegularTable(DataTableRenderer.java:234)
at org.primefaces.component.datatable.DataTableRenderer.encodeMarkup(DataTableRenderer.java:196)
at org.primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:82)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1764)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1757)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:724)

谢谢您的帮助。

4

1 回答 1

0
at java.lang.String.charAt(String.java:658)
at com.sun.faces.application.view.MultiViewHandler.getResourceURL(MultiViewHandler.java:341)

似乎图像的 url 是一个空字符串。检查返回prod.urlImg

于 2013-08-03T09:46:26.683 回答