我在嘗試在數據表中顯示列表時遇到NumberFormatException。我知道發生這種例外的一般原因,但無法弄清楚它適用於我的情況。在數據表中使用List <CustomObject>時出現NumberFormatException
這是我冰:數據表顯示的代碼
<ice:dataTable id="transformations" var="transformationList" width="700"
value="#{ShowStatusBean.transformationStatusList}" rows="10"
partialTriggers="refreshButton" autoSubmit="true">
<ice:column>
<ice:outputText value="#{transformationList.businessDate}" />
</ice:column>
<ice:column>
<ice:outputText value="#{transformationList.service}" />
</ice:column>
<ice:column>
<ice:outputText value="#{transformationList.status}" />
</ice:column>
</ice:dataTable>
而且我支持bean代碼
public List<TransformationBean> getTransformationStatusList() {
transformationStatusList = new ArrayList<TransformationBean>();
transformationStatusList.add(new TransformationBean("2012-01-01", "serviceName", "status1"));
transformationStatusList.add(new TransformationBean("2012-01-02", "serviceName2", "status2"));
return transformationStatusList;
}
最後的堆棧跟蹤
23:59:57 ERROR [f-tuning)'] D2DFaceletViewHandler - Problem in renderResponse: For input string: "businessDate"
java.lang.NumberFormatException: For input string: "businessDate"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:449)
at java.lang.Integer.parseInt(Integer.java:499)
at com.sun.facelets.el.LegacyELContext$LegacyELResolver.getValue(LegacyELContext.java:138)
at com.sun.el.parser.AstValue.getValue(AstValue.java:96)
at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:183)
at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
at com.sun.facelets.el.LegacyValueBinding.getValue(LegacyValueBinding.java:56)
at javax.faces.component.UIOutput.getValue(UIOutput.java:80)
at com.icesoft.faces.renderkit.dom_html_basic.OutputTextRenderer.encodeEnd(OutputTextRenderer.java:91)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:539)
at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:369)
at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:364)
at com.icesoft.faces.component.ext.renderkit.TableRenderer.encodeChildren(TableRenderer.java:896)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:527)
at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:357)
at com.icesoft.faces.renderkit.dom_html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:95)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:527)
at com.icesoft.faces.component.util.CustomComponentUtils.renderChild(CustomComponentUtils.java:338)
at com.icesoft.faces.component.panelpopup.PanelPopupRenderer.encodeBegin(PanelPopupRenderer.java:240)
at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:515)
at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:355)
at com.icesoft.faces.renderkit.dom_html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:95)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:527)
at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:357)
at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:364)
at com.icesoft.faces.renderkit.dom_html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:95)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:527)
at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:357)
at com.icesoft.faces.renderkit.dom_html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:95)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:527)
at com.icesoft.faces.component.util.CustomComponentUtils.renderChild(CustomComponentUtils.java:338)
at com.icesoft.faces.component.paneltabset.PanelTabSetRenderer.writeTabCell(PanelTabSetRenderer.java:983)
at com.icesoft.faces.component.paneltabset.PanelTabSetRenderer.encodeEnd(PanelTabSetRenderer.java:422)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:539)
at javax.faces.component.UIData.encodeEnd(UIData.java:573)
at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:369)
at com.icesoft.faces.renderkit.dom_html_basic.GridRenderer.encodeChildren(GridRenderer.java:207)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:527)
at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:357)
at com.icesoft.faces.renderkit.dom_html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:95)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:527)
at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:357)
at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:364)
at com.icesoft.faces.renderkit.dom_html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:95)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:527)
at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:357)
at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:364)
at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:364)
at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:364)
at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:364)
at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:364)
at com.icesoft.faces.renderkit.dom_html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:95)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:527)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:490)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:495)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:495)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:495)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:495)
at com.icesoft.faces.facelets.D2DFaceletViewHandler.renderResponse(D2DFaceletViewHandler.java:281)
at com.icesoft.faces.application.D2DViewHandler.renderView(D2DViewHandler.java:155)
at com.icesoft.faces.application.ViewHandlerProxy.renderView(ViewHandlerProxy.java:70)
at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:41)
at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:132)
at com.icesoft.faces.webapp.http.core.JsfLifecycleExecutor.apply(JsfLifecycleExecutor.java:51)
at com.icesoft.faces.webapp.http.core.ReceiveSendUpdates.renderCycle(ReceiveSendUpdates.java:171)
at com.icesoft.faces.webapp.http.core.ReceiveSendUpdates.service(ReceiveSendUpdates.java:112)
at com.icesoft.faces.webapp.http.core.RequestVerifier.service(RequestVerifier.java:65)
at com.icesoft.faces.webapp.http.servlet.BasicAdaptingServlet.service(BasicAdaptingServlet.java:48)
at com.icesoft.faces.webapp.http.servlet.SessionVerifier.service(SessionVerifier.java:58)
at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:55)
at com.icesoft.faces.webapp.http.servlet.SessionDispatcher.service(SessionDispatcher.java:77)
at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:55)
at com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet.java:192)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at com.icesoft.faces.webapp.xmlhttp.BlockingServlet.service(BlockingServlet.java:67)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3730)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3696)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2273)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1490)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
而且我TransformationBean
public class TransformationBean{
private String businessDate;
private String service;
private String status;
// constructor
// getter and setters
}
我研究過這個問題,發現了很多答案。但它看起來像我沒有做任何這些錯誤..所以不知道我錯過了什麼。 這些是我發現的關於同一問題的其他鏈接。
Number format exception when returning values from database(JPA)
NumberFormatException for input String
http://jforum.icesoft.org/JForum/posts/list/16645.page
所有這些提到<>正在從Java代碼返回的列表是Object []的 名單這就是爲什麼它試圖讓通過將屬性視爲索引屬性來處理數組條目。但是,從我的代碼中,清楚地知道我沒有返回Object []列表,但是已正確定義列表
我還測試了JUNit測試用例中的java代碼,並驗證了返回類型是TransformationBean對象列表。
我不正確做什麼,鄉親?
你能告訴我什麼「** TransformationBean **」是什麼意思?並告訴我類型爲TransformationBean的參數。 – Ponmalar
TrasformationBean只是我的POJO ..將它添加到 –
以上的原始文章中您是否嘗試將列表作爲託管bean的屬性並在getter中使用方法填充它? –