在基于Spring的Web应用程序中处理会话过期事件 [英] handle session expired event in spring based web application
问题描述
我在我的应用程序中使用Spring安全功能,但是我发现,当会话过期时,所有请求ajax都返回页面login.jsp(在HTTP响应中,不重定向,它将所有html内容放入)我的Web应用程序的登录页面. 我在应用程序中使用了很多ajax请求,目标是返回某些错误代码,例如510,而不是登录页面.
I am using Spring security feature in my application, but I found out that when the session expired, all the request ajax return the page login.jsp(not redirect, in http response, it puts all the html content) which is the login page of my webapp. I used a lot of ajax request in my app and the goal is return certain error code like 510 instead of the login page.
<session-management session-authentication-strategy-ref="example" />
没有无效的会话网址 我试图使invalid-session-url =",不起作用. 非常感谢
without invalid-session-url I tried to make invalid-session-url = "", doesn't work. Many thanks
推荐答案
使用自定义
在<http>
元素
Define a bean and use it as entry-point-ref
in <http>
element:
<http entry-point-ref="authenticationEntryPoint">
<!-- more configuration here -->
</http>
<bean id="authenticationEntryPoint"
class="com.example.spring.security.AjaxAwareAuthenticationEntryPoint">
<constructor-arg value="/login.jsp"/>
</bean>
这篇关于在基于Spring的Web应用程序中处理会话过期事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!