At the time of registration, the same user registered many times, and many pieces of the same data also appeared in the database. The background has been verified, and the js at the front desk has also limited the submission time to two seconds, but there will still be many pieces.

  java, question

At the time of registration, the same user registered many times, and many pieces of the same data also appeared in the database. The background has been verified, and the js at the front desk has also limited the submission time to two seconds, but there will still be many pieces.

Front end control:

var isSubmitting = false;
 if(!  isSubmitting){
 $.ajax({
 type: "post",
 Data: {uuid: uuid, other: data},//uuid is generated by the backend when the registration page is loaded
 contentType: "application/json",
 url: "/caiyongji.com/submit",
 beforeSend: function () {
 //Variable Control (js Angle)
 isSubmitting = true;
 //Disable button (browser angle, delay may occur)
 $("#submit").attr({ disabled: "disabled" });
 },
 success: function (data) {
 //Success
 },
 complete: function () {
 $("#submit").removeAttr("disabled");
 isSubmitting = false;
 bracket
 });
 bracket

Back-end control:

//There is no cache component on hand. Write one simply.
 private static ConcurrentMap<String, String> cache = new ConcurrentHashMap<>();
 public void preventDuplicateSubmit(String uuid, Object other){
 if (StringUtils.isEmpty(cache.get("uuid"))) {
 cache.put("uuid", uuid)
 //Continue
 }else{
 return;
 bracket
 bracket