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 contained in the request with the token value included in the current user session before processing the request. No match. After the request is processed, a new token will be generated before the reply is sent to the client, and the token is removed to the client. The old token saved in the user session will be replaced. This way if the user retires to the submission page and submit it again, the client passes The token is inconsistent with the token of the server, thereby effectively preventing 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 the user session ID and the current system time, the specific implementation can refer to TokenPro GenerateToken () method in the CESSOR class. 1. // Verify the transaction control token, 2. In Action: // IF (! iStokenvalid (Request)) Errors.Add (actionerroS.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); } }