0
我需要在註銷後停止用戶向後重定向。我嘗試使用以下方法停止向後重定向:如何在JSP中調用註銷後停止向後重定向?
1)使用servlet將標頭cache-control
更改爲no-cache,no-store
。 但它只有在使用servlet重定向到頁面時才起作用。
2)然後我用一個Servlet過濾器,以執行相同任務
doFilter(){
HttpServletResponse httpResponse = (HttpServletResponse) response;
httpResponse.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
httpResponse.setHeader("Pragma", "no-cache");
httpResponse.setDateHeader("Expires", 0);
}
3)使用meta標籤來清除緩存
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="pragma" content="no-cache" />
當我落後重定向到一個正常的頁面一樣index
,我仍然可以在標題(用戶名,購物車等)中看到登錄詳細信息。
最後,我嘗試在開發人員工具中禁用緩存,它工作。這不切實際。
如何停止向後重定向(如在Facebook中)?
謝謝。
*「當我向後重定向至指數正常的頁面,我還是CA看到頭(用戶名,購物車等登錄信息.. )「*你的意思是你將這些東西存儲在cookie中而不是服務器端會話中?然後停止這樣做。 – developerwjk