当前位置:网站首页>Form repeated submission problem
Form repeated submission problem
2022-06-23 09:37:00 【Linging_ twenty-four】
There are several situations in which forms are submitted repeatedly :
- The user repeatedly clicks the submit button ( Asynchronous requests )
- The network is not good , Cause the user to think that there is no click , So I clicked submit repeatedly ( Synchronization request , Forwarding causes )
- Users submit forms , Forward to another page , Then click refresh to cause repeated submission ( Synchronization request , Forwarding causes )
- Users submit forms , Forward to another page , Then click the browser to return to the previous step , Then continue to submit the form ( Synchronization request , Forwarding causes )
Solution :
Synchronization request :
1、JSP The page generates a random value , As the only form id, Place this unique value in Session in , Make a hidden field in the form to store the value , When you submit the form , Submit the form data and the unique value to the background , And then get it in the background session Unique value saved in , Will be backstage session Value and the unique value passed from the front-end form :
- Front end unique value id
==Background unique value id Express : First form submission , Then put the backstage session Value delete , Forward to a page . - Front end unique value id
!=Background unique value id Express : Resubmitted forms , You can redirect to a page .
Asynchronous requests :
1、 General idea : Generate a random value at the front end , Then pass it to the backstage , The background to use Aop To intercept , Take random values as key, Request data as value, Store in redis in , And set expiration time .aop Interception can be used to customize an annotation , load controller On the way . When the user clicks the submit button repeatedly , Methods marked with custom annotations will be intercepted , Get into aop Interception method , Judge in the surround notification , Whether in redis There is the key, If there is a duplicate submission, return or return the original data , If it does not exist, set it in , And set expiration time , The expiration time is controllable , In the user-defined annotation, you can use a user-defined method to obtain the expiration time .
2、 After sending the request , Use js Hide button , Or set the countdown button to click .
github:xxx
边栏推荐
- Gstore weekly gstore source code analysis (IV): black and white list configuration analysis of security mechanism
- ARM中常见的英文解释
- 全局快门和卷帘快门的区别
- 高性能算力中心 — NVMe/NVMe-oF — NVMe-oF Overview
- Set the CPU to have 16 address lines and 8 data lines, and use mreq as the access control line number Connection between memory and CPU
- Redis learning notes - transactions
- Gorm 高级查询
- [SUCTF 2019]CheckIn
- 2022 Gdevops全球敏捷运维峰会-广州站精华回放(附ppt下载)
- Common English explanations in arm
猜你喜欢

Learn SCI thesis drawing skills (E)

什么是BFC?BFC可以解决什么问题
![[GXYCTF2019]BabySQli](/img/51/a866a170dd6c0160ce98d553333624.png)
[GXYCTF2019]BabySQli

Typora set up image upload service

UEFI learning 3.6 - ACPI table on ARM QEMU
![[SUCTF 2019]CheckIn](/img/0e/75bb14e7a3e55ddc5126581a663bfb.png)
[SUCTF 2019]CheckIn
![[geek Challenge 2019] hardsql](/img/73/ebfb410296b8e950c9ac0cf00adc17.png)
[geek Challenge 2019] hardsql

Gstore weekly gstore source code analysis (IV): black and white list configuration analysis of security mechanism

学习SCI论文绘制技巧(E)

UEFI 源码学习4.1 - PciHostBridgeDxe
随机推荐
什么是闭包函数
ionic5表单输入框和单选按钮
Three methods to find the limit of univariate function -- lobida's rule and Taylor's formula
Implementation of s5p4418 bare metal programming (replace 2ndboot)
Neither rain nor sunshine
Go 单元测试
分布式常见面试题
AI系统前沿动态第38期:谷歌已放弃TensorFlow?;训练大模型的四种GPU并行策略;LLVM之父:模块化设计决定AI前途
JSP getting started summary
Mysql database introduction summary
Redis学习笔记—redis-cli详解
Go语言JSON 处理
RBtree
What is a closure function
Redis learning notes RDB of persistence mechanism
Redis学习笔记—主从复制
RGB and CMYK color modes
全局快门和卷帘快门的区别
Learn SCI thesis drawing skills (E)
Redis learning notes - Database Management