2016-07-14 34 views
2

我的应用程序大约80%是Spring MVC,但我有相当多的使用Webflow的代码。我目前正在使用Spring MVC SimpleUrlHandlerMapping发送到webflow,我知道这并不是我“应该”这样做的方式。从Spring MVC调度到Spring Webflow

我的流定义定义如下:

  • /WEB-INF/flows/process1/reservation/reservation-flow.xml
  • /WEB-INF /流/过程1 /修改/修改 - flow.xml
  • /WEB-INF/flows/process2/reservation/reservation-flow.xml
  • /WEB-INF/flows/process2/modify/modify-flow.xml

我想是可以通过以下URL来访问它们:

我的流量注册表豆看起来是这样的:

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

我的JavaScript来分派到一个Webflow看起来像这样(JavaScript片段,这是一个非常复杂的页面):

var form = $('<form action="${pageContext.request.contextPath}/process1/reservation/reservation.html" method="POST">'); 

    form.append('<input name="param1" value="' + record.param1 + '" />'); 
    form.append('<input name="param2" value="' + record.param2 + '" />'); 
    form.append('</form>'); 
    submitForm(form); 

现在对于真正的问题:如何建立一个URL处理程序映射它,无论是SimpleUrlHandlerMapping还是别的?

谢谢!

+0

因此,您应该使用'SimpleUrlHandlerMapping'而不是'FlowHandlerMapping',这是您“应该”这样做的原因吗?如果我正确地理解了你所要问的,不应该用'FlowHandlerMapping'给你想要的东西? – dbreaux

+0

正如@dbreaux提到的那样,有没有什么特别的推理背后没有使用FlowHandlerMapping.Also,您是否探索过使用子流并在流映射配置文件中添加更多转换。 –

+0

我没有使用FlowHandlerMapping的原因是它从来没有为我工作。 在我的基本路径,我想有这样的: /process1/reservation/reservation.xml 我预计映射到: http://example.com/context/process1/reservation/reservation。 html 但没有运气。 – Jason

回答

0

通常,如果你想通过Spring的MVC派遣请求,网络流量,我们必须 设立FlowHandlerAdapter像:

<!-- Enables FlowHandler URL mapping --> 
<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter"> 
    <property name="flowExecutor" ref="flowExecutor" /> 
</bean> 

,然后定义flowMapping:

<!-- Maps request paths to flows in the flowRegistry; 
    e.g. a path of /movie/showtime looks for a flow with id "movie/showtime" --> 
<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping"> 
    <property name="flowRegistry" ref="flowRegistry"/> 
    <property name="order" value="0"/> 
</bean> 

对于细节实现,你也可以参考spring文档。