简体   繁体   English

重新加载网页-浏览器的“后退”按钮(HTML / JSP)

[英]Reload web page - browser “back” button ( HTML/JSP)

I have a small issue. 我有一个小问题。 In my web application I use jsp forms. 在我的Web应用程序中,我使用jsp表单。

There is a form and it's data gets stored in a database when user submit the form. 有一个表单,当用户提交表单时,数据就会存储在数据库中。 Upon a successful submission, user is redirected to a confirmation page. 成功提交后,用户将被重定向到确认页面。

However, when the user press the "back" button of the browser, user is redirected to the previous form.(No server side interaction/No updated data from the database) And when the user press submit,that data is also saved in DB. 但是,当用户按下浏览器的“后退”按钮时,用户将被重定向到先前的表单。(没有服务器端交互/没有来自数据库的更新数据)并且当用户按下Submit时,该数据也保存在DB中。 Since this is an account related application, this behavior is not acceptable. 由于这是与帐户相关的应用程序,因此这种行为是不可接受的。

My question is, is there a way to prevent this behavior? 我的问题是,有没有办法防止这种行为?

Created a solution using javascript based on Luca's idea and it worked.Now when user press the back button, form is filled with the updated and latest data from database. 根据Luca的想法创建了一个使用javascript的解决方案,并且成功了。

<input type="hidden" id="refreshed" value="no">
    <script type="text/javascript">

           onload=function(){
               var e=document.getElementById("refreshed");
               if(e.value=="no")e.value="yes";
               else{e.value="no";location.reload();}
           }

    </script>

Thanks :) 谢谢 :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM