简体   繁体   English

Spring Web Flow:将视图状态ID附加到URL

[英]Spring Web Flow: append view state id to URL

I am using spring web flow 2.x and is trying to append the view state id to the URL. 我正在使用Spring Web Flow 2.x,并尝试将视图状态ID附加到URL。 I want to save the view state id to request scope and append it to URL everytime user clicks 'next' or 'previous'. 我想保存视图状态ID以请求范围,并在用户每次单击“下一个”或“上一个”时将其附加到URL。 Is this possible using a Custom Flow URL handler? 是否可以使用“自定义流URL”处理程序?

How do I get the view state Id inside my Custom/Pretty flow Url handler? 如何在“自定义/俏丽流” URL处理程序中获取视图状态ID?

Write an on-entry action in the view and retrieve current state id by RequestContext. 在视图中编写一个on-entry操作,并通过RequestContext检索当前状态ID。

<view-state id="currentView" view="currentView" model="modelObject">
    <on-entry>
        <evaluate expression="yourObject.methodName(flowRequestContext, flowScope.modelObject)"/>
    </on-entry>
    <transition on="previous" to="someStateOrView"/>
    <transition on="next" to="someStateOrView"/>
 </view-state>      

 public class YourObject{
...
public void methodName(RequestContext requestContext, ModelObject model){
    model.setPreviousView(requestContext.getCurentState().getId());
    ....
}
 }

Get the previousView value from your model and append it to your url as this will be set the moment flow enters into this view. 从模型中获取previousView值并将其附加到您的url,因为它将在流进入该视图时进行设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM