我有3 jsp pages(index.jsp, result1.jsp,result2.jsp)
一个servlet
。处理如下:
索引.jsp
<form method="post" action="MYSERVLET" >
<input type="text" name="studentname" id="studentname"/>
<input type="submit" value="click" />// goes to a servlet named as MYSERVLET
</form>
MYSERVLET
String t=request.getParameter("studentname");
------fetching data from database and sending to result1.jsp------
String nextJSP = "/result1.jsp";
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(nextJSP);
dispatcher.forward(request,response);
结果1.jsp
// 从 servlet 中检索数据并在其中显示数据result1.jsp
并将相同的值传递给result2.jsp
out.println(retrieved result from servlet);
<a href="result2.jsp?somestring=<%out.println(retrieved result from servlet);%>"> <%out.println(retrieved result from servlet);%></a>// after clicking on "retrieved result from servlet" i am passing this retrieved value to another jsp result2.jsp and also retrieving some data from database as follows:
结果2.jsp
String w=request.getParameter("somestring");
out.println(w);
我想给出一个back button here (in result2.jsp)
,以便在单击back button
后将我带到result1.jsp
可以看到以前显示的数据的位置(out.println(retrieved result from servlet);)
。但是,当我单击浏览器后退按钮(在 result2.jsp 中)时,每次警报即将到来"Confirm Form Resubmission"
,然后我重新加载该页面以查看(out.println(retrieved result from servlet);)
,我想避免此警报,我该如何避免呢?我怎样才能在没有任何警报的情况下直接看到该页面?