<script language="javascript"> 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> <html:form action="myAction.do" method="post" onsubmit="return checkSubmit();">
<html:form action="myAction.do" method="post" onsubmit="getElById('submitInput') .disabled = true; return true; "> <html:image styleId="submitInput" src="images/ok_b.gif" border="0" /> </html:form>
if (isTokenValid(request, true)) { // your code here return mapping.findForward("success"); } else { saveToken(request); return mapping.findForward ("submitagain"); }
//<input type="hidden" name="org.apache.struts.taglib.html.TOKEN" // value="6aa35341f25184fd996c4c918255c3ae"> if (!isTokenValid(request)) errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.transaction.token")); resetToken(request); //删除session中的令牌
protected String generateToken (HttpServletRequest request) { HttpSession session = request.getSession(); 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); } }
Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved. 闵涛 E_mail:admin@mintao.net(欢迎提供学习资源)
鄂公网安备 42011102001154号
站长:MinTao ICP备案号:鄂ICP备11006601号-18