Token (token) mechanism can solve the problem of repeated submission of forms, the basic principle is that the server side will be before processing the arrival request.
The token value included in the request is compared to the token value saved in the current user session to see if it matches. After processing the request, and before replying to the client, a new token will be generated, which will replace the old token saved in the user session in addition to the client. This way, if the user retires to the submission page and submit it again, the token passed by the client is inconsistent with the token of the server, and effectively prevents the occurrence of repeated submission.
At this time, it is actually two points, first: You need to have this token value in the request, how to save the token value in the request, actually to save some information in the page in the page, by hiding the field Saved, saved form, such as: , this value is genettoken () in the TokenProcessor class, is Calculated according to the current user's session ID and the LONG value of the current time. Second: After the client is submitted, we must consistent with the value included in the request, because the server will generate new token each time, so if it is repeated submit, the client's token value and The server-side token value is inconsistent. Here is to explain how to prevent repetition in the database. Transfer from: http://www.matrix.org.cn/blog/allen/archives/000677.html