create-base-teek-theme
Version:
``` npm create base-teek-theme@latest my-first-blog ```
44 lines (29 loc) • 1.02 kB
Markdown
date: 2025-04-05 01:57:38
title: 防重提交
permalink: /pages/1eec9f
tags:
- Spring Boot
author:
name: 华总
link: https://xiaoying.org.cn
categories:
- 后端
- 功能扩展
- 通用模块
::: tip
为防止用户在短时间内多次提交相同请求,系统提供了防重复提交功能。通过简单的注解配置,即可实现此功能。
:::
## [使用防重提交](https://www.youlai.tech/youlai-boot/3.开发指南/4.防重提交.html#使用防重提交)
在需要防重复提交的接口上添加 `@RepeatSubmit` 注解即可。通过注解参数 `expire`,可以灵活控制重复提交的时间间隔(单位:秒)。如果不设置,默认时间为 5 秒。
示例:
```java
@Operation(summary = "新增用户")
@PostMapping
@RepeatSubmit(expire = 3) // 3 秒内禁止重复提交
public Result<?> saveUser( @RequestBody @Valid UserForm userForm) {
// TODO 新增用户逻辑
return Result.success();
}
```