1
我为我的应用使用了struts2jquery网格插件。我正在使用拦截器会话超时,我正在配置我的会话超时在web.xml中,但问题是会话超时后,它不会要求页面说login.jsp,我的struts.xml如下。Struts2会话过期
....
<interceptors>
<interceptor name="SessionCheckInterceptor" class="com.org.SessionCheckInterceptor" />
<interceptor-stack name="testSessionValidationStack">
<interceptor-ref name="SessionCheckInterceptor" />
<interceptor-ref name="defaultStack" />
</interceptor-stack>
</interceptors>
...
<action name="mytable" class="com.org.MyTable">
<interceptor-ref name="testSessionValidationStack"/>
<result name="success" type="json"/>
<result name="error">messages.jsp</result>
<result name="sessionexpired">login.jsp</result>
</action>
...
我能够在调试时进入拦截器类,但它不会将我重定向到登录页面。请有人告诉我在我的代码中有什么问题?
我的拦截方法..
public String intercept(ActionInvocation actionInvocation) throws Exception {
ActionContext context = actionInvocation.getInvocationContext();
Map<String, Object> sessionMap = context.getSession();
log.info(" retrived session..." + sessionMap);
if (sessionMap == null || sessionMap.isEmpty()
|| sessionMap.get("userName") == null) {
log.info(" session expired...");
addActionError(actionInvocation,"Session has been expired,please login again.");
return "sessionexpired";
}
String actionResult = actionInvocation.invoke();
return actionResult;
}
你可以告诉你拦截器的方法代码 – 2012-07-20 06:08:07
我正在用拦截器方法代码编辑我的问题。 – ppb 2012-07-20 06:20:55
为什么你不使用像Spring Security这样的安全框架?处理所有这些事情,为您处理更多。 – Hugo 2012-07-20 06:26:54