JSF的h:dataTable问题

时间:2022-09-17 10:54:22
现有一ArrayList,欲在页面上显示,先在后台放入sessionMap中:
ArrayList users = new ArrayList();
users.add(user1);
users.add(user2);
    facesContext.getExternalContext().getSessionMap().put("users", users);

再在页面上显示:
<h:dataTable id="users" value="#{users}" var="user" rowClasses="oddRow, evenRow" headerClass="tableHeader">
    <h:column>
        <f:facet name="header">
    <h:panelGroup>
                <h:outputText value="Name" />     </h:panelGroup>
        </f:facet>
<h:outputText value="#{user.displayName}" />
   </h:column>
</h:dataTable>
但现在页面出不来,错误信息是:
javax.servlet.ServletException: For input string: "size"
javax.faces.webapp.FacesServlet.service(FacesServlet.java:154)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:264)
org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:107)
org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:72)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:110)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
org.acegisecurity.ui.switchuser.SwitchUserProcessingFilter.doFilter(SwitchUserProcessingFilter.java:335)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:142)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
org.acegisecurity.wrapper.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:81)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:217)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:191)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
org.acegisecurity.securechannel.ChannelProcessingFilter.doFilter(ChannelProcessingFilter.java:138)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:148)
org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:90)
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

root cause

java.lang.NumberFormatException: For input string: "size"
java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
java.lang.Integer.parseInt(Integer.java:447)
java.lang.Integer.parseInt(Integer.java:497)
com.sun.facelets.el.LegacyELContext$LegacyELResolver.getValue(LegacyELContext.java:138)
com.sun.el.parser.AstValue.getValue(AstValue.java:117)
com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:192)
com.sun.facelets.el.ELText$ELTextVariable.toString(ELText.java:174)
com.sun.facelets.el.ELText$ELTextComposite.toString(ELText.java:115)
com.sun.facelets.compiler.CommentInstruction.write(CommentInstruction.java:38)
com.sun.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:39)
com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:232)
com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:239)
com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:239)
com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:580)
org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:41)
org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:132)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:140)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:264)
org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:107)
org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:72)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:110)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
org.acegisecurity.ui.switchuser.SwitchUserProcessingFilter.doFilter(SwitchUserProcessingFilter.java:335)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:142)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
org.acegisecurity.wrapper.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:81)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:217)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:191)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
org.acegisecurity.securechannel.ChannelProcessingFilter.doFilter(ChannelProcessingFilter.java:138)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:148)
org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:90)
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
搞不懂这个和Size有什么关系?

5 个解决方案

#1


http://caterpillar.onlyfun.net/GossipCN/JSF/SimpleTable.htm
↑参考

#2


我又检查了一遍,感觉没什么问题,一个Collection对象放在datatable里,那这个java.lang.NumberFormatException: For input string: "size"异常到底是怎么回事?

#3


首先datatable不支持Collection套Collection,另外别把简单的问题复杂化.

#4


我的users这个ArrayList里放的是user类,一个有displayName属性和相关getter,setter的bean,所以不存在Collection套Collection的问题,但这个异常还是挺奇怪,不知和collection的size有什么关系?

#5


没人回答,自己顶先

#1


http://caterpillar.onlyfun.net/GossipCN/JSF/SimpleTable.htm
↑参考

#2


我又检查了一遍,感觉没什么问题,一个Collection对象放在datatable里,那这个java.lang.NumberFormatException: For input string: "size"异常到底是怎么回事?

#3


首先datatable不支持Collection套Collection,另外别把简单的问题复杂化.

#4


我的users这个ArrayList里放的是user类,一个有displayName属性和相关getter,setter的bean,所以不存在Collection套Collection的问题,但这个异常还是挺奇怪,不知和collection的size有什么关系?

#5


没人回答,自己顶先