On the server side to determine whether the form is repeated, the main consideration in the page through the session to share the flag variable method to achieve, that is, in the client page set session in the flag variable, and then in the server segment on the session of the flag variable to judge.
1. Create a new servertest.jsp file with the following code:
<%@ page language="java" contentType="text/html; charset=Gb2312"
pageEncoding="Gb2312"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=GB2312">
<title>提交页面</title>
<%
//设置标志变量SubmitFlag值ServerTest.jsp
session.putValue("SubmitFlag","ServerTest.jsp");
%>
<body bgcolor="#ffffff">
<form name="form_client" action="ServerSubmit.jsp">
<input type="checkbox" name="check_1" checked=true/>人在江湖
<input type="submit" name="submitok"/>
</form>
</body>
2. Create a new serversubmit.jsp with the following code:
<%@ page language="java" contentType="text/html; charset=Gb2312"
pageEncoding="Gb2312"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=Gb2312">
<title>服务器端程序</title>
<%
String PageFlag;
PageFlag=(String) session.getValue("SubmitFlag");
if(PageFlag=="Over"){
out.println("重复提交页面!");
}else{
//设置标志变量SubmitFlag值为Over,表示已经提交
session.putValue("SubmitFlag","Over");
out.println("正常业务逻辑处理...请等待!!!");
}
%>
<body>
</body>
3. When you click Submit Query, click Back, and then click the Submit Query Content button again to prompt for a duplicate commit error.