由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - How to prevent double submission in web form?
相关主题
Spring MVC question.菜鸟请教个问题,关于time limit exceeded
Help! (转载)再请教一个lucene的问题
JSF有前途吗How to redirect standard input in java
Anyone wants to talk about web frameworks?Question of POP&SMTP server connection
javascript 画多边形?Build web server and dispatcher?
关于开源项目清教关于编译原理
Web前端的HTML+JavaScript+CSS可以理解为MVC吗?关于Jsp timeout
纯ajax的app是不是比mvc的要难很多Re: 有没有办法在browser第一次访问的时候知道是不是支持cookie?
相关话题的讨论汇总
话题: submission话题: double话题: prevent话题: form话题: javascript
进入Java版参与讨论
1 (共1页)
g*****g
发帖数: 34805
1
I am using spring MVC, some form simply takes a while before a result can be
returned. Impatient user will click the button multiple times, is there
any built-in function in spring to prevent double submissions?
The redirect after submit will prevent browser refresh double submission,
but not double click button submission problem.
b**l
发帖数: 25
2
cco-ask

be

【在 g*****g 的大作中提到】
: I am using spring MVC, some form simply takes a while before a result can be
: returned. Impatient user will click the button multiple times, is there
: any built-in function in spring to prevent double submissions?
: The redirect after submit will prevent browser refresh double submission,
: but not double click button submission problem.

c*****t
发帖数: 1879
3
JavaScript to disable the button.

be

【在 g*****g 的大作中提到】
: I am using spring MVC, some form simply takes a while before a result can be
: returned. Impatient user will click the button multiple times, is there
: any built-in function in spring to prevent double submissions?
: The redirect after submit will prevent browser refresh double submission,
: but not double click button submission problem.

g*****g
发帖数: 34805
4
I'd rather rely on some server side solution.
What if user clicks quickly and the javascript is slow?
Use a token in session seems to be a good solution.
Spring has a handleInvalidSubmission function in AbstractFormController
which should be overrided.
Check google, you can do it multiple times, and you'll only
receive one email.

【在 c*****t 的大作中提到】
: JavaScript to disable the button.
:
: be

c*****t
发帖数: 1879
5
Well, certainly you can also use a unique id to acompany each submission
so the duplicate submission can be easily detected, but I think that is
rather unnecessary. Another common approach is to use a time counter to
internally ignore submissions during very short durations for the same
request from the same session.
Just speaking from experiences of dealing CGI and JavaScript.

【在 g*****g 的大作中提到】
: I'd rather rely on some server side solution.
: What if user clicks quickly and the javascript is slow?
: Use a token in session seems to be a good solution.
: Spring has a handleInvalidSubmission function in AbstractFormController
: which should be overrided.
: Check google, you can do it multiple times, and you'll only
: receive one email.

m******t
发帖数: 2416
6
javascript can't be relied on, but it's still useful - saves a server trip
whenever possible.
There are a few server-side solutions:
1. Set sessionForm to true in the controller. A duplicated submission would
come when there isn't a form in the session (having been consumed by the
first one), which would make it invalid. This isn't a fail-safe solution.
There can be race conditions.
2. As coconut said, generate a token/timestamp and put it in a hidden field.
If a token comes in for the second ti

【在 g*****g 的大作中提到】
: I'd rather rely on some server side solution.
: What if user clicks quickly and the javascript is slow?
: Use a token in session seems to be a good solution.
: Spring has a handleInvalidSubmission function in AbstractFormController
: which should be overrided.
: Check google, you can do it multiple times, and you'll only
: receive one email.

g*****g
发帖数: 34805
7

would
What do you mean race condition? Open 2 windows and click them side
by side? If that's the case, I don't think it'll be a problem for
my current project, I'll just pick whichever to submit.
field.
an

【在 m******t 的大作中提到】
: javascript can't be relied on, but it's still useful - saves a server trip
: whenever possible.
: There are a few server-side solutions:
: 1. Set sessionForm to true in the controller. A duplicated submission would
: come when there isn't a form in the session (having been consumed by the
: first one), which would make it invalid. This isn't a fail-safe solution.
: There can be race conditions.
: 2. As coconut said, generate a token/timestamp and put it in a hidden field.
: If a token comes in for the second ti

m******t
发帖数: 2416
8

Yeah, something like that. I guess practically it's not as serious as the
race conditions in program code. Could be a little wacky if you need to run
automated load tests though.

【在 g*****g 的大作中提到】
:
: would
: What do you mean race condition? Open 2 windows and click them side
: by side? If that's the case, I don't think it'll be a problem for
: my current project, I'll just pick whichever to submit.
: field.
: an

1 (共1页)
进入Java版参与讨论
相关主题
Re: 有没有办法在browser第一次访问的时候知道是不是支持cookie?javascript 画多边形?
请帮忙看看这个编译错误关于开源项目
再问generic问题:tomcat编译错误Web前端的HTML+JavaScript+CSS可以理解为MVC吗?
新手问一个弱问题, 关于从stdin输入int或者其他数值的实现方法纯ajax的app是不是比mvc的要难很多
Spring MVC question.菜鸟请教个问题,关于time limit exceeded
Help! (转载)再请教一个lucene的问题
JSF有前途吗How to redirect standard input in java
Anyone wants to talk about web frameworks?Question of POP&SMTP server connection
相关话题的讨论汇总
话题: submission话题: double话题: prevent话题: form话题: javascript