简体   繁体   English

JSF2:在导航规则中使用EL。 超时重定向?

[英]JSF2: Using EL in navigation rules. Redirect on timeout?

I am wondering the following: 我想知道以下几点:

When a request comes into the JSF servlet, is it possible to redirect to a session timeout page if a session bean indicates that the session has not been logged in? 当请求进入JSF servlet时,如果会话bean指示会话尚未登录,是否可以重定向到会话超时页面?

For example: 例如:

<navigation-rule>
    <from-view-id>*</from-view-id>
    <navigation-case>
        <if>#{not userBean.loggedIn}</if>
        <to-view-id>/login.jsf</to-view-id>
        <redirect/>
    </navigation-case>
</navigation-rule>

Obviously it would need to exclude the login.jsf from this rule...but you get the point. 显然,这需要从此规则中排除login.jsf ...但是您明白了。 I have tried something similar and it does not appear to work, and even if it did, how would it deal with Bookmarked URLS? 我已经尝试过类似的方法,但它似乎无法正常工作,即使可以了,如何处理带有书签的URL?

How best to implement this in JSF2? 如何最好地在JSF2中实现呢? Also, is there anything like the global.asax from ASP.NET in JSF2, or are PhaseListeners/Filters about it? 另外,是否有类似JSF2中ASP.NET的global.asax之类的东西,还是有关它的PhaseListeners / Filters?

Thank you. 谢谢。

Navigation rules would not be a good place for this sort of functionality since the NavigationHandler is not invoked until quite late in the lifecycle (Invoke Application). 对于此类功能,导航规则将不是一个好地方,因为直到生命周期的很晚才调用NavigationHandler (调用应用程序)。

替代文字
(source: ibm.com ) (来源: ibm.com


You can use declarative security (in the web.xml) to redirect to a login page. 您可以使用声明性安全性 (在web.xml中)重定向到登录页面。 Alternatively, you can redirecting using a Filter if you want finer grain control over what happens. 另外,如果您希望对发生的情况进行更精细的控制,则可以使用“ 过滤器”进行重定向。

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

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