4

首先,我不知道如何为spring webflow配置restful url请求,例如,输入地址时如何调用我的webflow: http://localhost/app/order/edit/1002

编写spring mvc控制器来处理这个很容易,但是在webflow的情况下,我不知道如何传递参数。

有谁能够帮我?谢谢

4

2 回答 2

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 bean:

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;
    }
}
于 2011-01-14T07:09:27.550 回答
0

RequestPathFlowExecutorArgumentHandler是您要找的吗?

流执行器参数处理程序,从请求路径中提取参数并在 URL 路径中公开它们。

这允许 REST 样式的 URL 以一般格式启动流:http://${host}/${context path}/${dispatcher path}/${flowId}

<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>
于 2010-09-21T10:20:36.390 回答