如何在使用F5/刷新页面时删除参数值?期望的结果是,当B.jsp将状态返回给A.jsp时,如果用户按下刷新页面按钮,我希望将该值设置为空。
A.jsp:
<%String VALUE = request.getParameter("STATUS");%>
B.jsp:
<%send.responseRedirect("A.jsp?STATUS="Y");%>
String param = request.getParameter("param");
if (session.getAttribute("PARAM") == null) {
out.print("This is a NEW request");
session.setAttribute("PARAM", request.getParameter("param"));
} else if (session.getAttribute("PARAM").toString().equalsIgnoreCase(param)) {
out.print("This is a REFRESH");
session.removeAttribute("PARAM");
} else {
out.print("This is a NEW request");
session.setAttribute("PARAM", request.getParameter("param"));
}
使用“newjsp.jsp?param=xyz123”调用它,然后尝试刷新。
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />