RepeatSubmit prevents repeated submission of annotations based on the framework
In the RuoYi framework, the @RepeatSubmit annotation is used to prevent repeated submissions from form.
When you add this annotation on the form submit button, if the framework is used, double verification will be performed on the front-end and back-end to ensure that the same user will not submit the same form repeatedly in a short period of time.
Here is a simple example
Add @RepeatSubmit annotation on the controller method
import ; import ; import ; import ; @RestController public class UserController { @PostMapping("/submit") @RepeatSubmit public String submitForm(@RequestBody User user) { // Process form submission logic return "success"; } }
In the front-end page, add the repeat-submit class to the submit button:
<form > <!-- Form content --> <button type="submit" class="btn btn-primary repeat-submit">submit</button> </form>
In front-end JavaScript code, add logic to prevent duplicate submissions:
$(document).ready(function () { $('#form').on('submit', function (e) { (); if (!) { = true; (); setTimeout(() => { = false; }, 5000); // Repeated submissions are prohibited within 5 seconds } else { alert('Please do not repeat submissions! '); } }); });
In this example, we added the @RepeatSubmit annotation to the controller method and added the corresponding processing logic to the front-end page and JavaScript code.
In this way, when the user tries to submit the form repeatedly, a prompt message will be received and the form will not be submitted repeatedly.
The @RepeatSubmit annotation in the framework can help you easily implement the function of preventing repeated form submissions and improve system stability and security.
Summarize
The above is personal experience. I hope you can give you a reference and I hope you can support me more.