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
|