解决双重提交问题 [英] Solving the Double Submission Issue

查看:29
本文介绍了解决双重提交问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想看看 Web 开发人员如何避免双重提交问题.所以基本上我对问题的理解如下:

I would like to see how Web Developers avoid the double submission problem. So basically my understanding of the problem is as follows:

当不耐烦的用户多次提交表单时,会发生两次提交,从而导致问题.这个问题可以通过 JavaScript(特别是 jQuery 脚本)来解决,一旦表单被提交就会禁用提交按钮——如果客户端禁用了 JavaScript,则这是一个弱点.

Double submission occurs when an impatient user submits a form multiple times, causing issues. This problem can be fixed by JavaScript (specifically jQuery scripts) that disable the submit button once the form has been submitted - a weakness of this is if clients have JavaScript disabled.

还有服务器端的检测方法.

There is also server side methods of detection.

所以我的问题是:

人们如何克服双重服从?双重提交引起的问题的现实生活示例是什么?是否有任何 Web 应用程序框架内置了双重提交工具?

推荐答案

如果您正在使用 Java 服务器端脚本并使用 struts 2,那么您可以参考这个讨论使用令牌的链接.

If you are working with java server side scripting and also using struts 2 then you refer this link which talks about on using token .

http://www.xinotes.org/notes/note/369/

应该为初始页面渲染生成一个令牌并保存在会话中,当请求与令牌第一次一起提交时,在 struts 操作中,运行一个以线程名称作为令牌 ID 的线程,并运行任何逻辑客户端已请求,当客户端再次提交相同的请求时,检查线程是否仍在运行(thread.getcurrentthread().interrupted)如果仍在运行则发送客户端重定向503.

A token should be generated and kept in session for the initial page render, when the request is submitted along with the token for the first time , in struts action run a thread with thread name as the token id and run the logic whatever the client has requested for , when client submit again the same request, check whether the thread is still running(thread.getcurrentthread().interrupted) if still running then send a client redirect 503.

请看struts 2code的ExecuteAndWaitInterceptor,这个结合token的逻辑有助于快速点击

Please look at the ExecuteAndWaitInterceptor of struts 2code, the logic of this combined with token will help out fast click

这篇关于解决双重提交问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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