栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

JSF 2,Spring Security 3.x和Richfaces 4在会话超时时重定向到登录页面以处理ajax请求

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

JSF 2,Spring Security 3.x和Richfaces 4在会话超时时重定向到登录页面以处理ajax请求

由于你使用的是Spring Security 3.0.x,因此可以按此处所述使用自定义sessionManagementFilter

com.icesoft.spring.security.JsfRedirectStrategy类在此处可用

如果你使用的是Spring Security 3.1.x,请进行以下更改

 <beans:bean id="sessionManagementFilter" >    <beans:constructor-arg name="securityContextRepository" ref="httpSessionSecurityContextRepository" /> <!-- this permits redirection to session timeout page from javascript/ajax or http -->    <beans:property name="invalidSessionStrategy" ref="jsfRedirectStrategy" /></beans:bean><beans:bean id="jsfRedirectStrategy" >  <beans:constructor-arg name="invalidSessionUrl" value="/general/logins/sessionExpired.jsf" /></beans:bean><beans:bean id="httpSessionSecurityContextRepository" />

对JSFRedirectStrategy类的唯一更改是前几行:

public class JsfRedirectStrategy implements InvalidSessionStrategy {protected final Log logger = LogFactory.getLog(getClass());      private String invalidSessionUrl;private boolean contextRelative;public JsfRedirectStrategy(String invalidSessionUrl){    this.invalidSessionUrl=invalidSessionUrl;}@Overridepublic void onInvalidSessionDetected(HttpServletRequest request,        HttpServletResponse response) throws IOException, ServletException {    String redirectUrl = calculateRedirectUrl(request.getContextPath(), invalidSessionUrl);

这也适用于IE8。如果你有兴趣,也可以查看此博客,但是我从未尝试过这样做,因为上面的操作要容易得多。

仅供参考:如果你不使用Spring,则有很多方法可以执行此操作:Primefaces在其站点上执行此操作。 或者通过导入Omnifaces jar 链接更简单



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/390567.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号