2010-09-21 157 views

回答

0

RequestPathFlowExecutorArgumentHandler你在找什麼?

流執行參數處理程序,從請求 路徑 提取參數和揭露他們的URL路徑。

這使得REST風格的URL來 推出的通用格式流: HTTP:// $ {HOST}/$ {背景 路徑}/$ {調度路徑}/$ {}流ID

<bean id="flowController" class="org.springframework.webflow.executor.mvc.FlowController"> 
    <property name="flowExecutor" ref="flowExecutor" /> 
    <property name="argumentHandler"> 
     <bean class="org.springframework.webflow.executor.support.RequestPathFlowExecutorArgumentHandler" /> 
    </property> 
</bean> 
+0

謝謝,JoseK。我想這就是我想要的,但仍然想知道如何使用像這樣的URL:http:// localhost/app/order/edit/1002來啓動流向eidt訂單1002的流程?你能給一些示例代碼嗎? – Tom 2010-09-23 08:14:36

+0

順便說一下,我使用的是spring webflow 2.1.1,我沒有在spring-webflow-2.1中找到class org.springframework.webflow.executor.mvc.FlowController和class org.springframework.webflow.executor.support.RequestPathFlowExecutorArgumentHandler .1.RELEASE.jar – Tom 2010-09-23 08:29:36

+0

您的鏈接基於1.0.x,而不是我的版本。 – Tom 2010-09-23 12:57:07

3

嘗試閱讀請求參數如下。 它處理「http://example.com/message?messageId=3」,但在渲染視圖時,URL更改爲「http://example.com/message?execution=e1s1」之類的內容。

流量代碼:

<?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"> 

    <on-start> 
     <evaluate expression="FooWebFlowController.create(flowRequestContext)" 
        result="flowScope.fooModel"/> 
    </on-start> 

    <view-state id="view" model="fooModel" view="fooView"> 
    </view-state> 
</flow> 

FooWebFlowController豆:

import org.springframework.webflow.execution.RequestContext; 

@Component 
public class FooWebFlowController { 

    @Autowired 
    private FooDAO fooDAO; 

    public Foo create(RequestContext requestContext) { 
     String messageId = requestContext.getRequestParameters().get("messageId") 
     Foo foo = fooDAO.findByMessagId(messageId); 
     return foo; 
    } 
}