s中的struts2:选择列表 - >请求的列表键''作为集合/数组/映射/枚举/迭代器类型

时间:2017-10-26 03:37:51

标签: java select struts2

我有以下struts2代码,当打开url时,它在字段中有异常:

标记'选择',字段'列出',name' loanForm.dobDay':请求的列表键' loanForm.dayRange&# 39;无法解析为集合/数组/映射/枚举/迭代器类型。例如:人或人。{name}

<s:select id="dobDay" name="loanForm.dobDay" value="%{loanForm.dobDay}"
                     list="loanForm.dayRange"
                        style="width:40px">
                    </s:select>

如果我编码为类对象的下面是否有问题?

 public LoanForm getLoanForm() {
        return (LoanForm) 
       ActionContext.getContext().getSession().get("loanForm");
    }

    public void setLoanForm(LoanForm loanForm) {
        ActionContext.getContext().getSession().put("loanForm", loanForm);
    }

-------------- LoanForm.java --------------

public List<String> getDayRange() {
        List<String> day = new ArrayList<String>();
        day.add("");
        for (int i=1; i<=31; i++) {
            day.add(String.valueOf(i));
        }

        return day;
    }

还有一个人发现了这个问题:

消息:标记&#39;选择&#39;,字段&#39; list&#39;,name&#39; loanForm.confirmationOfficeNt&#39;:请求的列表键&#39; #session .sBranchCatN&#39;无法解析为集合/数组/映射/枚举/迭代器类型。例如:人或人。{name}

<s:select value="%{loanForm.confirmationOfficeNt}" name="loanForm.confirmationOfficeNt" 
list="#session.sBranchCatN" id="loanFormLocationNT" listKey="key" listValue="value"/>

Full StackTrace如下:

org.apache.struts2.components.Component.fieldError(Component.java:260)
    org.apache.struts2.components.Component.findValue(Component.java:356)
    org.apache.struts2.components.ListUIBean.evaluateExtraParams(ListUIBean.java:84)
    org.apache.struts2.components.Select.evaluateExtraParams(Select.java:104)
    org.apache.struts2.components.UIBean.evaluateParams(UIBean.java:886)
    org.apache.struts2.components.UIBean.end(UIBean.java:535)
    org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:42)
    jsp_servlet._web_45_inf._jsp.__aeon_loan_form_step1._jsp__tag18(__aeon_loan_form_step1.java:1154)
    jsp_servlet._web_45_inf._jsp.__aeon_loan_form_step1._jsp__tag2(__aeon_loan_form_step1.java:411)
    jsp_servlet._web_45_inf._jsp.__aeon_loan_form_step1._jsp__tag1(__aeon_loan_form_step1.java:296)
    jsp_servlet._web_45_inf._jsp.__aeon_loan_form_step1._jspService(__aeon_loan_form_step1.java:212)
    weblogic.servlet.jsp.JspBase.service(JspBase.java:35)
    weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:286)
    weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:260)
    weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:137)
    weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:350)
    weblogic.servlet.internal.ServletStubImpl.onAddToMapException(ServletStubImpl.java:489)
    weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:376)
    weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:247)
    weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:630)
    weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:287)
    org.apache.struts2.result.ServletDispatcherResult.doExecute(ServletDispatcherResult.java:167)
    org.apache.struts2.result.StrutsResultSupport.execute(StrutsResultSupport.java:208)
    com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:366)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:270)
    com.oktify.web.interceptors.MobileInterceptor.intercept(MobileInterceptor.java:61)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:240)
    org.apache.struts2.factory.StrutsActionProxy.execute(StrutsActionProxy.java:54)
    org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:556)
    org.apache.struts2.dispatcher.ExecuteOperations.executeAction(ExecuteOperations.java:81)
    org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:113)
    weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)
    weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3701)
    weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3667)
    weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:326)
    weblogic.security.service.SecurityManager.runAsForUserCode(SecurityManager.java:197)
    weblogic.servlet.provider.WlsSecurityProvider.runAsForUserCode(WlsSecurityProvider.java:203)
    weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:71)
    weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2443)
    weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2291)
    weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2269)
    weblogic.servlet.internal.ServletRequestImpl.runInternal(ServletRequestImpl.java:1703)
    weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1663)
    weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:272)
    weblogic.invocation.ComponentInvocationContextManager._runAs(ComponentInvocationContextManager.java:352)
    weblogic.invocation.ComponentInvocationContextManager.runAs(ComponentInvocationContextManager.java:337)
    weblogic.work.LivePartitionUtility.doRunWorkUnderContext(LivePartitionUtility.java:57)
    weblogic.work.PartitionUtility.runWorkUnderContext(PartitionUtility.java:41)
    weblogic.work.SelfTuningWorkManagerImpl.runWorkUnderContext(SelfTuningWorkManagerImpl.java:644)
    weblogic.work.ExecuteThread.execute(ExecuteThread.java:415)
    weblogic.work.ExecuteThread.run(ExecuteThread.java:355)

1 个答案:

答案 0 :(得分:0)

对不起我的绿豆体验。 我已经解决了。 这是由于loanForm和其他变量中的null值。 我已经把getter检查它是否为null,然后初始化它。