2012-06-06 109 views
2

我從春季Web流程開始,閱讀並遵循文檔。我創建了一個新的流程:春季Web流程,創建子流程與輸入字段

測試flow.xml

<?xml version="1.0" encoding="UTF-8"?> 
<flow xmlns="http://www.springframework.org/schema/webflow" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation=" 
     http://www.springframework.org/schema/webflow 
     http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd"> 

    <var name="testName" class="com.project.TestView" /> 

    <view-state id="test"> 
     <on-entry> 
      <set name="flowScope.name" value="testName.name" /> 
     </on-entry> 
     <transition on="test" to="saveName"/> 
    </view-state> 

    <subflow-state id="subTest" subflow="testSub-flow"> 
     <input name="nameVar" value="name" /> 
     <transition to="error" /> 
    </subflow-state> 

    <view-state id="error" /> 
    <end-state id="finish" /> 
</flow> 

,我試圖創建一個testSub-flow.xml

<?xml version="1.0" encoding="UTF-8"?> 
<flow xmlns="http://www.springframework.org/schema/webflow" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation=" 
     http://www.springframework.org/schema/webflow 
     http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd"> 

    <input type="String" name="nameVar" /> 

    <on-start> 
     <evaluate expression="com.project.TestView.printSomething(nameVar)" result="flowScope.testPrint" /> 
    </on-start> 

    <view-state id="printTest" > 
     <transition on="restart" to="endSub" /> 
    </view-state> 

    <end-state id="endSub" /> 

</flow> 

調用的方法是:

@Transactional(readOnly = true) 
    public String printSomething(String text){ 
     System.out.print(text + " this is a test"); 
     return text + " this is a test"; 
    } 

我得到一些例外,當它加載主流瀏覽器,test-flow.xml

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.webflow.execution.ActionExecutionException: Exception thrown executing [[email protected] targetAction = [[email protected] expression = com.project.TestView.printSomething(nameVar), resultExpression = flowScope.testPrint], attributes = map[[empty]]] in state 'null' of flow 'test' -- action execution attributes were 'map[[empty]]' 

可能是什麼問題?提前致謝。

+0

該表達式期望存在一個id爲com.project.TestView的spring bean。是這樣嗎?這個例外應該稍微多一點 - 一個堆棧跟蹤可能會告訴你它是由EvaluationExpression引起的。無論您的異常處理機制是什麼,這件作品都可能被吞噬。 – kevin

回答

1

乍一看,它似乎找不到任何啓動狀態。嘗試在流標籤添加啓動狀態屬性:

<flow xmlns="http://www.springframework.org/schema/webflow" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation=" 
      http://www.springframework.org/schema/webflow 
      http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd" 
      start-state="test"> 

如果不解決這個問題,它可能是流生成器不能找到一個名爲「SAVENAME」狀態。這個問題可能是在這一行:

<transition on="test" to="saveName"/> 

如果你想調用子流程時,「測試」事件發生時,你寫的「分測驗」,而不是「SAVENAME」,以調用子流。

因此,該行應該是:

<transition on="test" to="subTest"/> 

另外請注意,您沒有指定這些視圖狀態的任何觀點。

希望這會有所幫助。