问题描述
我用的是Struts2框架,我的问题是
I am using Struts2 framework, my problem is
如果用户登录系统并点击了一些动作,比如说ACTION1
,流程将进入动作类并执行一些方法,返回适当的结果.他可能会访问一些网页,然后再次点击ACTION1
.
If user log-in into system and clicked some action lets say ACTION1
, flow will go to action class and executes some method, return appropriate result.
He may visit some of the web pages, and again clicked ACTION1
.
只要他在同一个会话中,现在控件不应该去那个特定的方法,但结果应该和以前的结果一样.
As long as he is in the same session, now the control should not go that particular method but the result should be same as previous results.
我们怎样才能做到这一点?
How can we achieve this?
推荐答案
你可以试试 tokenSession
拦截器.
You can try a tokenSession
interceptor.
此拦截器基于 token
拦截器构建,提供处理无效令牌的高级逻辑.与普通令牌不同拦截器,此拦截器将尝试提供智能在使用同一会话的多个请求的情况下进行故障转移.也就是说,它会阻塞后续请求,直到第一个请求被完成,然后不是返回 invalid.token
代码,而是将尝试显示与原始有效的相同响应如果没有多个请求,则将显示操作调用首先提交.
This interceptor builds off of the
token
interceptor, providing advanced logic for handling invalid tokens. Unlike the normal token interceptor, this interceptor will attempt to provide intelligent fail-over in the event of multiple requests using the same session. That is, it will block subsequent requests until the first request is complete, and then instead of returning theinvalid.token
code, it will attempt to display the same response that the original, valid action invocation would have displayed if no multiple requests were submitted in the first place.
它将防止重复提交相同的操作或重复使用您通过 s:token
标签.
It will prevent from double submit the same action or reuse the same token that you provide with s:token
tag.
说明
停止重复提交表单.
令牌标签用于帮助双击";提交问题.如果您使用 TokenInterceptor
或TokenSessionInterceptor
.s:token
标签只是放置一个隐藏的包含唯一标记的元素.
The token tag is used to help with the "double click" submission
problem. It is needed if you are using the TokenInterceptor
or the
TokenSessionInterceptor
. The s:token
tag merely places a hidden
element that contains the unique token.
将标签放在您的表单中,您再也不会重复提交同一个表单了.令牌会话拦截器将尝试通过返回与第一种情况相同的响应来为您处理无效令牌.
Place the tag inside your form and you never get back in submitting the same form twice. Token session interceptor will try to handle invalid token for you by returning the same response like in first case.
这篇关于只要用户在当前会话中,就防止调用两次相同的操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!