1 JavaScript, set a variable, only allowed to be submitted once.
Var checksubmitflg = false;
Function checksubmit () {
if (Checksubmitflg == True) {
Return False;
}
CHECKSUBMITFLG = true;
Return True;
}
Document.ondblclick = function doCondblclick () {
Window.Event.ReturnValue = false;
}
Document.onclick = function doconclick () {
IF (Checksubmitflg) {
Window.Event.ReturnValue = false;
}
}
script>
2 or JavaScript, set the submit button or Image to disable
οnsubmit = "getelbyid ('submitinput'). Disabled = true; return true;">>>>>> html: form> 3 Using Struts synchronous token mechanism With the synchronous token mechanism to solve the problem of repeated submission in the web application, Struts also gives a reference implementation. Fundamental: The server side compares the token value included in the request with the token value included in the current user session before processing the request. 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. IF (ISTOKENVALID (Request, True) { // Your Code Here Return mapping.findforward ("Success"); } else { SaveToken (Request); Return mapping.findforward ("Submitagain"); } Struts generates a unique (for each session) token according to user session ID and current system time, and specific implementation can refer to the generateToken () method in the TokenProcessor class. 1. // Verify the transaction control token, 2. In Action: // IF (! iStokenValid (Request) Errors.Add (ActionerRors.global_ERROR, New Actionerror ("Error.Transaction.token)); ResetToken (Request); / / Delete token in Session 3. Action has such a way to generate a token Protected string generateToken (httpservletRequest request) { HttpSession session = request.getations (); Try { BYTE ID [] = session.getid (). getBytes (); Byte now [] = NEW long (system.currenttimemillis ()). TOSTRING (). getBytes (); MessageDigest MD = MessageDigest.getInstance ("MD5"); Md.Update (ID); Md.Update (now); Return (tohex (md.digest ())); } catch (IllegalStateException E) { Return (NULL); } catch (nosuchalgorithmexception e) { Return (NULL); } }