【发布时间】:2011-04-15 02:13:24
【问题描述】:
首先,我不知道如何为spring webflow配置restful url请求, 例如,输入地址时如何调用我的 webflow: http://localhost/app/order/edit/1002
很容易写spring mvc控制器来处理这个,但是在webflow的情况下,我不知道如何传递参数。
有人可以帮助我吗? 谢谢
【问题讨论】:
标签: spring-webflow
首先,我不知道如何为spring webflow配置restful url请求, 例如,输入地址时如何调用我的 webflow: http://localhost/app/order/edit/1002
很容易写spring mvc控制器来处理这个,但是在webflow的情况下,我不知道如何传递参数。
有人可以帮助我吗? 谢谢
【问题讨论】:
标签: spring-webflow
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>
【讨论】:
尝试读取请求参数,如下所示。 它处理“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;
}
}
【讨论】: