如何向spring webflow传递参数?

发布于 2024-09-24 06:33:26 字数 258 浏览 3 评论 0原文

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

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

有人可以帮助我吗? 谢谢

First of all, I don't know how can config restful url request for spring webflow,
for example,how can I invoke my webflow when type address:
http://localhost/app/order/edit/1002

It's easy to write spring mvc controller to handle this,but in case of webflow, I don't know how to pass parameters.

Can anybody help me?
Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

甜味超标? 2024-10-01 06:33:26

尝试读取请求参数,如下所示。
它处理“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;
    }
}

Try reading request parameter like following.
It processes "http://example.com/message?messageId=3" but when rendering view, the URL changes to something like "http://example.com/message?execution=e1s1".

Flow code:

<?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;
    }
}
缪败 2024-10-01 06:33:26

RequestPathFlowExecutorArgumentHandler 您在寻找什么?

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

这允许 REST 风格的 URL
一般格式的启动流程:
http://${主机}/${上下文
路径}/${调度程序路径}/${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>

Is the RequestPathFlowExecutorArgumentHandler what you're looking for?

Flow executor argument handler that
extracts arguments from the request
path and exposes them in the URL path.

This allows for REST-style URLs to
launch flows in the general format:
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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文