Spring Web Flow 防止后退按钮使用
因此,我在项目上使用 Spring Web Flow,并希望在元素上使用history="discard" 和history="invalidate" 属性。
我已将这些属性放置在我想要的位置,但是,当我在转换上运行历史记录属性后尝试通过导航到视图来测试它们是否有效时,它会将我定向到异常页面。
org.springframework.web.util.NestedServletException:请求处理失败;嵌套异常是 org.springframework.webflow.execution.repository.FlowExecutionRestorationFailureException:使用键“e1s1”恢复流程执行时发生问题
所以可以肯定,它说我从历史记录中删除了该状态,因此找不到它。我真的不明白为什么没有一些内置的机制来处理这个问题,但除此之外,我还没有找到一种方法来优雅地处理这个异常,这样我就可以重定向它们到错误页面或者将它们发送回它们来自的地方会更好。
<view-state id="page1">
<transition on="gotoNextPage" to="page2" history="invalidate" />
</view-state>
<view-state id="page2"/>
这种行为应该如何实现,以便按下第 2 页上的后退按钮不会产生异常,而只是让您停留在第 2 页?
So I'm using Spring Web Flow on a project and want to make use of the history="discard" and history="invalidate" attributes on elements.
I have placed those attributes where I want them, however, when I try to test whether or not they work by navigating to a view after the history attribute is run on the transition, it directs me to an exception page.
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.webflow.execution.repository.FlowExecutionRestorationFailureException: A problem occurred restoring the flow execution with key 'e1s1'
So sure, it's saying I deleted that state from the history so it can't find it. I don't really see why there isn't some built in mechanism to handle this in the first place, but that aside, I haven't been able to figure out a way to gracefully handle this exception so that I can just redirect them to an error page or would be nicer to just send them back to where they came from.
<view-state id="page1">
<transition on="gotoNextPage" to="page2" history="invalidate" />
</view-state>
<view-state id="page2"/>
How is this behavior supposed to be achieved, so that pressing the back button on page2 does not create an exception but just leaves you at page 2?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我对此做了很多搜索。
这个旧论坛帖子< /a> 有 2 个解决方案(带有示例代码)。
第一个是捕获异常并显示一个页面,该页面使用 javascript
forward()
返回到原始页面 - 实际上撤消了后退页面。第二个解决方案检查流状态并将其发送到最近的有效流快照。
我和你一样困惑,没有现成的解决方案。每个人都一定会遇到这个问题。
对于那些有兴趣跟踪进展的人,有一个 JIRA 问题提交。
I did a lot of searching on this.
This old forum post has 2 solutions (with sample code).
The first is to catch the exception and display a page that use javascript to
forward()
back to the original page - in effect undoing the back.The 2nd solution examines the flow state and sends them to most recent valid flow snapshot.
I'm as perplexed as you are that there is no out of box solution. Everyone must encounter this issue.
There is a JIRA issue filed for those interested in following the progress.