简体   繁体   English

用户提交后退按钮时如何重新加载同一页面

[英]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.

相关问题 用户单击浏览器的后退按钮时如何重新加载当前页面 - How to reload current page when user click back button of browser 在浏览器后退按钮或重新加载页面时注销用户 - Logout user on browser back button or when reload page 单击后退按钮时重新加载页面angularjs - Reload page when back button is clicked angularjs 单击后退按钮时重新加载浏览器页面 - reload browser page when click back button 当用户从 React Native 中的另一个页面导航回页面时,如何重新加载页面? - How to reload a page, when user navigates back to the page from another page in React Native? 是否可以在单击浏览器后退按钮时重新加载同一页面? - is it possible to reload the same page on clicking browsers back button? 用户单击上一页的后退按钮后如何重新加载网页? - How to reload a webpage after user clicks back button from previous page? 如何在重新加载页面时清除HTML表单,但如何在用户导航回该页面时清除? - How do you clear an HTML form on page reload but not when the user navigates BACK to the page? 单击浏览器后退按钮时如何保持在同一页面上 - How to stay on the same page when clicking the browser back button 单击来自同一域的后退按钮时重新加载网页 - Reload webpage when clicking back button from same domain
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM