帮助在春季捕获会话超时 [英] Help catching session timeout in spring
问题描述
我有一个简单的Spring 3 MVC应用程序。我正在使用sessionAttribute,一切正常,除非我让页面停留30分钟或更长时间。然后我得到一个
I have a simple Spring 3 MVC application. I am using a sessionAttribute and everything works fine except when I let the page sit for 30 minutes or longer. I then get a
org.springframework.web.HttpSessionRequiredException
org.springframework.web.HttpSessionRequiredException
告诉我在会话中找不到我的对象。
telling me my object is not found in session.
我想我需要在会话超时发生时以某种方式重定向回同一页面。我不确定如何使用spring正确地执行此操作。
I am thinking I need to somehow redirect back to the same page when a session timeout occurs. I am not sure how to do this correctly with spring.
无需登录,我已经在检查对象是否为空。
There is no login required and I am already checking if the object is null.
任何建议都将受到赞赏。
Any suggestions would be appreciated.
谢谢
推荐答案
您可以将错误页面绑定添加到HttpSessionRequiredException,它将重定向到您应用程序中的第一页
You can add error-page binding to HttpSessionRequiredException which will redirect to first page in your application
示例:
web.xml
<web-app>
<error-page>
<exception-type>org.springframework.web.HttpSessionRequiredException</exception-type>
<location>/index.jsp</location>
</error-page>
</web-app>
这篇关于帮助在春季捕获会话超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!