public String intercept(ActionInvocation invocation) throws Exception {
//获取action名
String actionName = invocation.getInvocationContext().getName();
//是登录页面放行
if("login".equals(actionName)){
return invocation.invoke();
}
else{
ActionContext context = invocation.getInvocationContext();
Map session = (Map) context.get(ServletActionContext.SESSION);
if(session == null)
return "login_new";
else{
Object obj = session.get("TERM_INFO");
if(obj == null){
return "login_new";
}
else{
return invocation.invoke();
}
}
}
}
<interceptors>
<interceptor name="loginTest" class="com.risen.interceptor.LonginInterceptor"></interceptor>
<interceptor-stack name="sessionInsert">
<interceptor-ref name="loginTest"></interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="sessionInsert"></default-interceptor-ref>
<global-results>
<result name="login_new">/new.jsp</result>
</global-results>
请问如果拦截所有action 怎么让他只要不符合要求就跳转到登录页
------解决方案--------------------
异步请求过滤器不知道能不能跳转