- ·上一篇文章:教你理解复杂的C/C++声明
- ·下一篇文章:程序员的酸甜苦辣
JSP避免Form重复提交的三种方案
1 javascript ,设置一个变量,只允许提交一次。
<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" >
2 还是javascript,将提交按钮或者image置为disable
<html:form action="myAction.do" method="post"
>
<html:image styleId="submitInput" src="/it/UploadPic/2008-1/200811392838789.gif" border="0" />
</html:form>
javascript:window.open(this.src);" style="cursor: pointer;"/>
<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" >
2 还是javascript,将提交按钮或者image置为disable
<html:form action="myAction.do" method="post"
>
<html:image styleId="submitInput" src="/it/UploadPic/2008-1/200811392838789.gif" border="0" />
</html:form>
javascript:window.open(this.src);" style="cursor: pointer;"/>

