2012-07-18 41 views
1

我想提出一個Hello World Spring Web Flow的......我失去了什麼......我找不到任何好的例子,所以我開始做一個。有人可以告訴我,我錯過了什麼讓我的Hello World Flow工作。製作一個Hello World Spring Web Flow的......我缺少什麼

的web.xml

<?xml version="1.0" encoding="UTF-8"?> 
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
    id="WebApp_ID" version="2.5"> 
    <display-name>MyFlow</display-name> 
    <welcome-file-list> 
     <welcome-file>index.html</welcome-file> 
     <welcome-file>index.htm</welcome-file> 
     <welcome-file>index.jsp</welcome-file> 
     <welcome-file>default.html</welcome-file> 
     <welcome-file>default.htm</welcome-file> 
     <welcome-file>default.jsp</welcome-file> 
    </welcome-file-list> 
    <servlet> 
     <servlet-name>spring</servlet-name> 
     <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
     <load-on-startup>1</load-on-startup> 
    </servlet> 
    <servlet-mapping> 
     <servlet-name>spring</servlet-name> 
     <url-pattern>*.html</url-pattern> 
    </servlet-mapping> 
</web-app> 

彈簧servlet.xml中

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


    <context:component-scan base-package="org.uftwf.controller" /> 

    <bean id="viewResolver" 
     class="org.springframework.web.servlet.view.UrlBasedViewResolver"> 
     <property name="viewClass" 
      value="org.springframework.web.servlet.view.JstlView" /> 

     <property name="prefix" value="/WEB-INF/jsp/" /> 
     <property name="suffix" value=".jsp" /> 
    </bean> 
</beans> 

的HelloWorld-flow.xml

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE flow PUBLIC "-//SPRING//DTD WEBFLOW 1.0//EN" "http://www.springframework.org/dtd/spring-webflow-1.0.dtd"> 

<flow start-state="helloworld"> 
    <view-state id="helloworld" view="helloworld"> 
    </view-state> 
</flow> 

的index.jsp

<html> 
<head> 
    <title>Spring 3.0 MVC Series</title> 
</head> 
<body> 
    <a href="hello.html">Say Hello (Spring MVC)</a><p> 
    <a href="hello.html">Say Hello (Spring-Web-Flow)</a> 
</body> 
</html> 

所以我有什麼改變讓我的流量工作

+2

你缺少的配置是用SpringMVC電線春Webflow的。我的意思是,當調度員用SpringMVC得到請求,它應該有一些該請求發送到您的流..這些配置項目 - flowExecutor和flowRegistry等按照這個例子[鏈接] http://www.ervacon.com/products /swf/intro/index.html – RKodakandla 2012-07-25 16:26:35

回答

0

你錯過了上用SpringMVC-servlet.xml中

<!-- define controller mappings for webflow --> 
<bean id="webflowHandlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> 
    <property name="order" value="5"/> 
    <property name="mappings"> 
     <props> 
      <prop key="**/hello">flowController</prop> 
     </props> 
    </property> 
</bean> 

<!-- webflow configuration --> 
<import resource="spring-webflow.xml"/> 

而在你的流程文件中使用流解析:

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

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

<flow:flow-registry id="flowRegistry" base-path="/WEB-INF/flows" flow-builder-services="flowBuilderServices"> 
    <flow:flow-location-pattern value="/**/*-flow.xml"/> 
</flow:flow-registry> 

<flow:flow-executor id="flowExecutor" flow-registry="flowRegistry"/> 

可能有更多的,但遵循@rrkwells建議一個更完整的示例的鏈接。