• <small id='5WFlu'></small><noframes id='5WFlu'>

  • <tfoot id='5WFlu'></tfoot>
    1. <i id='5WFlu'><tr id='5WFlu'><dt id='5WFlu'><q id='5WFlu'><span id='5WFlu'><b id='5WFlu'><form id='5WFlu'><ins id='5WFlu'></ins><ul id='5WFlu'></ul><sub id='5WFlu'></sub></form><legend id='5WFlu'></legend><bdo id='5WFlu'><pre id='5WFlu'><center id='5WFlu'></center></pre></bdo></b><th id='5WFlu'></th></span></q></dt></tr></i><div id='5WFlu'><tfoot id='5WFlu'></tfoot><dl id='5WFlu'><fieldset id='5WFlu'></fieldset></dl></div>
        <bdo id='5WFlu'></bdo><ul id='5WFlu'></ul>
        <legend id='5WFlu'><style id='5WFlu'><dir id='5WFlu'><q id='5WFlu'></q></dir></style></legend>

        为什么注销后点击页面上的返回按钮会显示上一页内容?

        时间:2023-09-25
          <tbody id='J0xj3'></tbody>
            <bdo id='J0xj3'></bdo><ul id='J0xj3'></ul>
            • <small id='J0xj3'></small><noframes id='J0xj3'>

            • <i id='J0xj3'><tr id='J0xj3'><dt id='J0xj3'><q id='J0xj3'><span id='J0xj3'><b id='J0xj3'><form id='J0xj3'><ins id='J0xj3'></ins><ul id='J0xj3'></ul><sub id='J0xj3'></sub></form><legend id='J0xj3'></legend><bdo id='J0xj3'><pre id='J0xj3'><center id='J0xj3'></center></pre></bdo></b><th id='J0xj3'></th></span></q></dt></tr></i><div id='J0xj3'><tfoot id='J0xj3'></tfoot><dl id='J0xj3'><fieldset id='J0xj3'></fieldset></dl></div>
            • <tfoot id='J0xj3'></tfoot>

              1. <legend id='J0xj3'><style id='J0xj3'><dir id='J0xj3'><q id='J0xj3'></q></dir></style></legend>
                  本文介绍了为什么注销后点击页面上的返回按钮会显示上一页内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在处理一个 Struts 2 项目.当用户单击 logout 按钮时,logout 操作会使用 session.clear() 清除会话.

                  I am working on a Struts 2 project. When user clicks a logout button the logout action clears the session using session.clear().

                  但是当用户在登出后点击浏览器中的返回按钮时,仍然显示上一页内容.

                  But when user clicks the back button in the browser after logout, it still displays the previous page content.

                  如果退出后在浏览器中单击了 back 按钮,我想将用户重定向到登录页面.

                  I want to redirect an user to the login page, if the back button was clicked in the browser after logout.

                  在我的注销操作中我还有什么需要清除的以解决这个问题吗?

                  Is there anything else I should clear in my logout action to solve this problem?

                  推荐答案

                  原来您的浏览器在您按下返回按钮之前正在缓存页面.浏览器缓存机制旨在通过在页面具有相同 URL 时从本地缓存中获取页面来最小化服务器访问时间.当成千上万的客户端浏览服务器时,它显着减少了服务器负载,并且似乎非常有帮助.但在某些情况下,尤其是在您的情况下,内容应该更新.后退按钮的设计目的是缓存用户正在浏览的每个页面,并在按下后退按钮时从本地缓存中检索它们.因此,解决方案是告诉浏览器在返回带有控制浏览器缓存的特殊标头的响应时不允许缓存.在 servlet 环境中,您可以使用过滤器来关闭缓存,但在 Struts2 中,您可以使用自定义拦截器.例如

                  Turns out that your browser is caching pages before you press the back button. The browser caching mechanism is designed so to minimize the server access time by getting the page from the local cache if the page have the same URL. It significantly reduces the server load when browsing the server by thousands of clients and seems to be very helpful. But in some cases, especially in yours the content should be updated. The back button is designed so it caches every page that a user is browsing and retrieve them from the local cache when pressed the back button. So, the solution is to tell the browser to not allow caching when returning a response with a special headers that control the browser caching. In the servlet environment you might use a filter to turn off caching but in Struts2 you could use a custom interceptor. For example

                  public class CacheInterceptor implements Interceptor {
                  
                  private static final long serialVersionUID = 1L;
                  
                  @Override
                  public void destroy() {}
                  
                  @Override
                  public void init() {}
                  
                  @Override
                  public String intercept(ActionInvocation invoication) throws Exception {
                      HttpServletRessponse response = ServletActionContext.getResponse();
                      response.setHeader("Cache-Control", "no-cache");
                      response.setHeader("Pragma", "no-cache");
                      response.setHeader("Expires", "-1");
                      return invoication.invoke();
                  }
                  
                  }
                  

                  现在您可以配置此拦截器以供每个操作使用

                  Now you could configure this interceptor to use by every action

                  <package name="default" extends="struts-default" abstract="true">
                  
                      <interceptors>
                        <interceptor name="cache" class="org.yourcompany.struts.interceptor.CacheInterceptor "/>
                        <interceptor-stack name="cacheStack">
                          <interceptor-ref name="cache"/>
                          <interceptor-ref name="defaultStack"/>
                        </interceptor-stack>
                      </interceptors>
                      <default-interceptor-ref name="cacheStack"/>
                  
                  </package>
                  

                  当您的包扩展 default 包时,它们会继承拦截器和拦截器堆栈,您也可以通过操作配置覆盖此配置.

                  When your packages extend default package they inherit the interceptor and the interceptor stack, you can also override this configuration by the action configuration.

                  这篇关于为什么注销后点击页面上的返回按钮会显示上一页内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:通过 Struts 2 中的 ModelDriven 将参数传递给动作 下一篇:在 Prepare() 方法中找不到高级通配符映射参数

                  相关文章

                  • <bdo id='KGXMO'></bdo><ul id='KGXMO'></ul>
                  1. <tfoot id='KGXMO'></tfoot>

                    <small id='KGXMO'></small><noframes id='KGXMO'>

                    <i id='KGXMO'><tr id='KGXMO'><dt id='KGXMO'><q id='KGXMO'><span id='KGXMO'><b id='KGXMO'><form id='KGXMO'><ins id='KGXMO'></ins><ul id='KGXMO'></ul><sub id='KGXMO'></sub></form><legend id='KGXMO'></legend><bdo id='KGXMO'><pre id='KGXMO'><center id='KGXMO'></center></pre></bdo></b><th id='KGXMO'></th></span></q></dt></tr></i><div id='KGXMO'><tfoot id='KGXMO'></tfoot><dl id='KGXMO'><fieldset id='KGXMO'></fieldset></dl></div>

                      <legend id='KGXMO'><style id='KGXMO'><dir id='KGXMO'><q id='KGXMO'></q></dir></style></legend>