I have a basic POST form being submitted. Every time a form is submitted, a database is updated. If someone tries to refresh the page, you get a "Confirm form resubmission?". Is there anyway to avoid this? I know this is achievable with PHP but thats not an option here
Thanks!
The action that accepts your form POST should commit the data to the database and then redirect to another action. That way, when the user hits refresh, they will only be reading data, not writing it.
Here's an example:
public Result terminate(Long depositKey) throws Exception {
depositsService.cancelScheduledDeposit(getCurrentUser().memberKey(), depositKey);
return redirect(routes.ControllerFactory.deposits.terminateConfirmation(depositKey));
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With