只要用户在当前会话中,防止两次调用相同的操作 [英] Prevent same action called twice as long as user is in current session

查看:69
本文介绍了只要用户在当前会话中,防止两次调用相同的操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用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?

推荐答案

您可以尝试

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 the invalid.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.

这将防止您重复使用

It will prevent from double submit the same action or reuse the same token that you provide with s:token tag.

说明

停止重复提交表格.

Description

Stop double-submission of forms.

令牌标记用于帮助双击"提交 问题.如果您使用TokenInterceptorTokenSessionInterceptor. 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.

这篇关于只要用户在当前会话中,防止两次调用相同的操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆