2012-10-10 48 views
1

我在Web Flow應用程序中放置了一個簡單的Spring MVC,我無法在頁面上渲染flowExecutionUrl,以便導航到下一個州。我認爲這意味着流程沒有開始(是否有明確的觸發器?)。 我假設我的設置有問題,但日誌表明我正確註冊了flow.xml文件。

我的Spring配置(MVC-調度-servlet.xml中)是:

<beans xmlns="http://www.springframework.org/schema/beans" 
xmlns:context="http://www.springframework.org/schema/context" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:tx="http://www.springframework.org/schema/tx" 
xmlns:mvc="http://www.springframework.org/schema/mvc" 
xmlns:webflow="http://www.springframework.org/schema/webflow-config" 
xsi:schemaLocation=" 
    http://www.springframework.org/schema/beans  
    http://www.springframework.org/schema/beans/spring-beans-3.1.xsd 
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context-3.1.xsd 
    http://www.springframework.org/schema/tx 
    http://www.springframework.org/schema/tx/spring-tx-3.1.xsd 
    http://www.springframework.org/schema/mvc 
    http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd 
    http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd 
    http://www.springframework.org/schema/webflow-config 
    http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.3.xsd"> 
<context:component-scan base-package="com.intl.cigna.ecommerce.controller" /> 

<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 
    <property name="prefix"> 
     <value>/WEB-INF/view/</value> 
    </property> 
    <property name="suffix"> 
     <value>.jsp</value> 
    </property> 
</bean> 
<mvc:annotation-driven/> 

<!-- Forwards requests to the "/" resource to the "welcome" view --> 
<mvc:view-controller path="/" view-name="welcome"/> 

<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean"> 
    <property name="persistenceUnitName" value="com.intl.cigna"/> 

<!-- Configures Handler Interceptors --> 
<mvc:interceptors> 
    <!-- Changes the locale when a 'locale' request parameter is sent; e.g. /?locale=de --> 
    <bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" /> 
</mvc:interceptors> 

<!-- Saves a locale change using a cookie --> 
<bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver" /> 

<!-- Application Message Bundle --> 
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"> 
    <property name="basename" value="/WEB-INF/messages/messages" /> 
    <property name="cacheSeconds" value="0" /> 
</bean> 

<!-- Enables FlowHandler URL mapping --> 
<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter"> 
    <property name="flowExecutor" ref="flowExecutor" /> 
</bean> 
<webflow:flow-executor id="flowExecutor" /> 
<!-- 
    Maps request paths to flows in the flowRegistry; e.g. a path of 
    /hotels/booking looks for a flow with id "hotels/booking" 
--> 
<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping"> 
    <property name="flowRegistry" ref="flowRegistry" /> 
    <property name="order" value="0" /> 
</bean> 

<webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices"> 
    <webflow:flow-location path="/WEB-INF/view/flow.xml" /> 
</webflow:flow-registry> 

<webflow:flow-builder-services id="flowBuilderServices" 
    view-factory-creator="mvcViewFactoryCreator" /> 

<bean id="mvcViewFactoryCreator" 
    class="org.springframework.webflow.mvc.builder.MvcViewFactoryCreator"> 
    <property name="viewResolvers" ref="viewResolver" /> 
</bean> 

而且我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.xsd"> 

    <view-state id="step1" view="step1"> 
     <transition on="next" to="step2"/> 
     <transition on="cancel" to="cancel"/> 
    </view-state> 

    <view-state id="step2" view="step2"> 
     <transition on="previous" to="step1"/> 
     <transition on="finish" to="success"/> 
     <transition on="cancel" to="cancel"/> 
    </view-state> 

    <end-state id="success" view="flows/success"/> 

    <end-state id="cancel" view="flows/cancel"/> 

</flow> 

我可以成功導航到視圖。

我的JSP是:

<html> 
<head> 
    <title>spring mvc web flow</title> 
    <link rel="stylesheet" href="<c:url value="/resources/css/demo_page.css"/>" type="text/css"></link> 
    <link rel="stylesheet" href="<c:url value="/resources/css/demo_table.css"/>" type="text/css"></link> 
</head> 
<body id="dt_example"> 
    <div id="container"> 
     <div> 
      <p class="notice">This is step 1 of the web flow</p> 
      <form id="step1" action="${flowExecutionUrl}" method="POST"> 
       <button id="cancel" type="submit" name="_eventId_cancel">Cancel</button> 
       <button id="next" type="submit" name="_eventId_next">Next &gt;&gt;</button> 
       <a href="${flowExecutionUrl}&_eventId=next">Next</a> 
       <c:out value="${flowExecutionUrl}"/> 

      </form> 
     </div> 
    <%@ include file="/WEB-INF/view/footer.jsp" %> 
    </div> 
</body> 
</html> 

回答

1

好,我知道... 要開始流動,你需要使用流ID在URL中。所以在我的情況下,使用url'http:// localhost:8080/SpringMVC/flow'作爲id爲'flow'的流。 我假設當你指向視圖時流程開始。