2013-03-14 62 views
1

註銷後,我希望用戶永遠不會訪問該頁面,即使他們知道正確的URL並將其輸入。如果他們鍵入他們在登錄時看到的頁面的URL,則應將其重定向到主頁。如何防止用戶在註銷後使用鏈接訪問該頁面?

我使用的代碼中header.jsp文件

<core:if test="${userName == null}"> 
    <script> 
     parent.location.href='logout.html' 
    </script> 
</core:if> 

但由於頭被包含在這兩個公司簡介頁面和註冊頁面,我不得不創建這兩個文件不同的頁眉不包括上面的代碼。 有更好的解決方案嗎?

解釋

  1. 登錄並導航到該網址的網頁。複製頁面
  2. 註銷
  3. 的URL在同一瀏覽器窗口中粘貼

網站運行良好的URL沒有尋求任何登錄詳細信息。

回答

3

我不是很清楚你在問什麼,但在這裏我們去:
我假設你被彈簧安全的方式保護一些私人的網址,例如:

<security:http use-expressions="true"> 
    <!-- ...more configuration stuff --> 
    <security:intercept-url pattern="/private/*" access="isFullyAuthenticated()" /> 
    <!-- ...more configuration stuff --> 
    <security:logout invalidate-session="true" logout-url="/logout" logout-success-url="/yourUrlAfterLogout.html"/> 
</security:http> 

然後,當用戶註銷,他無法再訪問私人網址。
UPDATE:Spring Security的一部分完)

如果你想阻止用戶訪問這些受保護的頁面時,他按下返回鍵在導航或複製的私人網址,你可以配置WebContentInterceptor如下:

<mvc:interceptors> 
    <bean id="webContentInterceptor" 
     class="org.springframework.web.servlet.mvc.WebContentInterceptor"> 
     <property name="cacheSeconds" value="-1" /> 
     <property name="useExpiresHeader" value="true" /> 
     <property name="useCacheControlHeader" value="true" /> 
     <property name="useCacheControlNoStore" value="true" /> 
    </bean> 
</mvc:interceptors> 
+0

我還沒有在我的項目中實現spring-security。我需要的是,註銷後人們不應該能夠訪問頁面,他們應該能夠看到他們通常在沒有登錄的情況下看到的頁面。 通過添加解釋來編輯該問題。請檢查一下。 – puppuli 2013-03-15 04:58:08

+0

但是你使用spring mvc嗎?因爲我的答案的第二部分與彈簧安全無關,它只是彈簧mvc。無論如何,我會更新和澄清。 – Dani 2013-03-15 08:21:08

相關問題