我有2 jsp pages and one Servlet。我正在通过 servlet 从数据库中获取数据并将结果发送到result.jsp我显示结果的页面。但我想添加一个Back button,result.jsp通过点击back button我想去index.jsp,但问题是当我每次收到消息时都点击后退按钮Confirm form submission,这让我很恼火。我怎样才能避免这种情况Confirm form submission?也许它是在 servlet 中完成处理时出现的。
索引.jsp
<form method="post" action="Student">
<input type="text" name="studentname"/>
<input type="submit" value="search"/>
</form>
学生 servlet
String student_name=request.getParameter("studentname");
-------fetching data from database------------
-------------------sending to result.jsp------
String nextJSP = "/result.jsp";
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(nextJSP);
dispatcher.forward(request,response);
结果.jsp
//displaying data here
<form action="index.jsp">
<input type="submit" value="back"/>// a back button is here which is going to index.jsp
</form>
编辑
从result.jsp我要去另一个页面result1.jsp,如下所示
在result.jsp我写了以下内容:
<a href="result1.jsp.jsp?a code=<%out.println(student_name);%>"><%out.println(student_name);%></a>
通过单击上面的超链接,我去了result1.jsp
我想在此处添加一个后退按钮(在 result1.jsp 中),单击后我想对 result.jsp 执行操作,但是当单击后退按钮时,我Confirm form submission每次都会得到。我写了以下内容result1.jsp
<input type="button" value="Back" onclick="javascript:history.go(-1)">
我仍然收到该消息Confirm form submission。我怎样才能避免这种情况?我想result.jsp直接去没有这个消息。这怎么可能?