2016-02-02 60 views
0

方法getClientByCredential()將根據'clientType'返回一個Client子實例。春季無法訪問變量flowScope

客戶端是一個抽象類。班級個人和公司擴展客戶。所以我不能在flow.xml聲明變量客戶端這樣的:

<var name="client" class="somepackage.domain.Client" /> 

這裏是我的flow.xml,但它不會工作。

<view-state id="start"> 
    <transition on="credentialEntered" to="getClient"/> 
</view-state> 

<action-state id="getClient"> 
    <evaluate result="flowScope.client" expression="clientActions.getClientByCredential(requestParameters.clientType, requestParameters.credentialType, requestParameters.credentialNo)"/> 
    <transition to="clientReady"/> 
    <transition to="clientAddFork" on-exception="com.rtongsoft.loansystem.util.exception.ClientNotFoundException"/> 
</action-state> 

<action-state id="clientAddFork"> 
    <evaluate expression="requestParameters.clientType" /> 
    <transition on="INDIVIDUAL" to="individualAdd"/> 
    <transition on="COPORATE" to="coporateAdd"/> 
</action-state> 

<action-state id="coporateAdd"> 
    <transition to="cancel"/> 
</action-state> 

<view-state id="individualAdd" model="client"> <!-- the exception place --> 
    <on-render> 
     <evaluate result="viewScope.credentialTypeList" expression="entryService.getEntrysByfield('credentialType')"/> 
     <evaluate result="viewScope.nationalityList" expression="entryService.getEntrysByfield('nationality')"/> 
     <evaluate result="viewScope.ethnicGroupList" expression="entryService.getEntrysByfield('ethnicGroup')"/> 
     <evaluate result="viewScope.educationBackgroundList" expression="entryService.getEntrysByfield('educationBackground')"/> 
     <evaluate result="viewScope.genders" expression="T(com.rtongsoft.loansystem.enumeration.Gender).values()"/> 
     <evaluate result="viewScope.maritalStatuses" expression="T(com.rtongsoft.loansystem.enumeration.MaritalStatus).values()"/> 
    </on-render> 
    <transition on="submit" to="addClient"/> 
</view-state> 

<action-state id="addClient"> 
    <evaluate expression="clientService.addClient(flowScope.client)"/> 
    <transition to="clientReady"/> 
</action-state> 

<!-- flow end --> 
<end-state id="clientReady" > 
    <output name="client"/> 
</end-state> 
<end-state id="cancel" /> 

<global-transitions> 
    <transition on="cancel" to="cancel" /> 
</global-transitions> 

這裏是根異常:

> 02-Feb-2016 11:15:28.949 SEVERE [http-nio-8080-exec-2] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [DispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.webflow.execution.FlowExecutionException: Exception thrown in state 'individualAdd' of flow 'application'] with root cause 
java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'client' available as request attribute 
at org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:144) 
at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:168) 
at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getPropertyPath(AbstractDataBoundFormElementTag.java:188) 
at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getName(AbstractDataBoundFormElementTag.java:154) 
at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.autogenerateId(AbstractDataBoundFormElementTag.java:141) 
at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.resolveId(AbstractDataBoundFormElementTag.java:132) 
at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.writeDefaultAttributes(AbstractDataBoundFormElementTag.java:116) 
at org.springframework.web.servlet.tags.form.AbstractHtmlElementTag.writeDefaultAttributes(AbstractHtmlElementTag.java:422) 
at org.springframework.web.servlet.tags.form.SelectTag.writeTagContent(SelectTag.java:194) 
at org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:84) 
at org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:80) 
at org.apache.jsp.WEB_002dINF.flows.application.individualAdd_jsp._jspx_meth_form_005fselect_005f0(individualAdd_jsp.java:1660) 
at org.apache.jsp.WEB_002dINF.flows.application.individualAdd_jsp._jspx_meth_form_005fform_005f0(individualAdd_jsp.java:1482) 
at org.apache.jsp.WEB_002dINF.flows.application.individualAdd_jsp._jspService(individualAdd_jsp.java:378) 
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:725) 
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:431) 
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396) 
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:725) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:721) 
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:466) 
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:391) 
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:318) 
at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:168) 
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303) 
at org.springframework.webflow.mvc.servlet.ServletMvcView.doRender(ServletMvcView.java:55) 
at org.springframework.webflow.mvc.view.AbstractMvcView.render(AbstractMvcView.java:196) 
at org.springframework.webflow.engine.ViewState.render(ViewState.java:293) 
at org.springframework.webflow.engine.ViewState.refresh(ViewState.java:242) 
at org.springframework.webflow.engine.ViewState.resume(ViewState.java:220) 
at org.springframework.webflow.engine.Flow.resume(Flow.java:537) 
at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:259) 
at org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:169) 
at org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:228) 
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959) 
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893) 
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) 
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:618) 
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:725) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:85) 
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61) 
at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108) 
at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137) 
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) 
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66) 
at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449) 
at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365) 
at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90) 
at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83) 
at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383) 
at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362) 
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) 
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) 
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219) 
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) 
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501) 
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142) 
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) 
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610) 
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) 
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:516) 
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1086) 
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:659) 
at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:223) 
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1558) 
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1515) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) 
at java.lang.Thread.run(Thread.java:745) 

回答

0

我終於發現了問題。當getClientByCredential()拋出ClientNotFoundException時,它將永遠不會將客戶機實例返回給flowScope。 對不起,我的疏忽。

順便說一句,有沒有人知道如何設置

<var name="client" class="somepackage.domain.Client" /> 

當客戶端是一個抽象類。

varibale'client'將被分配客戶端子。個人或企業。