2013-05-14 88 views
-1

我知道 可以在faces-config.xml文件中設置導航規則。但在那裏,我只知道選擇以正確的流程進行導航。JSF中的導航規則

但我想避免未登錄的用戶在地址欄中輸入網址時直接進入主屏幕。 有沒有可能在配置文件中做到這一點,或者我必須寫一個Frontcontroller作爲一個類?

我的代碼:

<navigation-rule> 
    <from-view-id>/login.xhtml</from-view-id> 
    <navigation-case> 
     <from-outcome>register</from-outcome> 
     <to-view-id>/register.xhtml</to-view-id> 
    </navigation-case> 
    <navigation-case> 
     <from-outcome>succes</from-outcome> 
     <to-view-id>/home.xhtml</to-view-id> 
    </navigation-case> 
    <navigation-case> 
     <from-outcome>fail</from-outcome> 
     <to-view-id>/login.xhtml</to-view-id> 
    </navigation-case> 
</navigation-rule> 

希望你能幫助我。

+0

檢查:http://stackoverflow.com/questions/10154202/how-do-i-do-security-in-jsf問候 – 2013-05-14 09:57:34

回答

1

安全性不是由導航規則處理的東西。使用過濾器爲您處理它(我會建議Spring security)。