[英]How to reload the same page when user submits the back button
I am submitting my form page and on successful insertion into DB, it is redirected to success page.我正在提交我的表单页面,并在成功插入数据库后,它被重定向到成功页面。 When I click back button from success page,it comes back to form page with populating old values in respective fields.当我从成功页面单击后退按钮时,它会返回表单页面,并在各个字段中填充旧值。 How can I reload the same success page restricting the browser to go back to previous page.如何重新加载相同的成功页面,限制浏览器返回上一页。
When u use back button or link ?当您使用后退按钮或链接时?
I think u should use button for back button?我认为你应该使用按钮作为后退按钮?
use Response.sendRedirect(theFirstPageURL);
使用Response.sendRedirect(theFirstPageURL);
in servlet.在 servlet 中。
Try this: <a href="javascript:history.go(0)">Click to refresh the page</a>
试试这个: <a href="javascript:history.go(0)">Click to refresh the page</a>
or you could use this in your html header if you're ok with no caching at all:或者,如果您完全没有缓存,则可以在 html 标题中使用它:
<meta http-equiv="cache-control" content="no-cache">
after successful submission , reset the form (using jquery or javascript).成功提交后,重置表单(使用 jquery 或 javascript)。 so that you cannot see the old values.这样您就看不到旧值。
use:用:
String s = request.getRequestURL();
to get the current page url获取当前页面的url
and then use the form for your submit button and pass the param 's' in your form action然后将表单用于提交按钮并在表单操作中传递参数“s”
<form action="<%=s%>"</form>
You cant control browser's back button because it fetch value from cache storage of browser.您无法控制浏览器的后退按钮,因为它从浏览器的缓存存储中获取值。 Yes you can stop back button url for that you have to set no cache in response type of servlet and you have to change configuration file and add interceptor so that when that url fires interceptor detect that url and reload your current page.是的,您可以停止后退按钮 url,因为您必须在 servlet 的响应类型中不设置缓存,并且必须更改配置文件并添加拦截器,以便在该 url 触发时拦截器检测到该 url 并重新加载当前页面。
You can stop caching of you jsp page by adding this line in your servlet from where jsp is called:您可以通过在调用 jsp 的 servlet 中添加以下行来停止缓存 jsp 页面:
response.setHeader("Cache-Control", "private, no-store, no-cache,must-revalidate"); response.setHeader("Pragma", "no-cache");
You just need to autocomplete="off" into your Form-Tag.您只需要在您的表单标签中添加 autocomplete="off" 即可。
Like this:-像这样:-
<form class="form-horizontal" method="post" enctype="multipart/form-data" id="Nform" autocomplete="off">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.