struts2 extjs json-default 拦截器
我做了一个extjs 和struts2集成的项目,现在遇到一个问题,要写一个拦截器当session超时时返回登录页面。现在自己定义的拦截器拦截到了请求,但是页面没有跳转,哪位大侠看到了能不能帮着解答一下;
UserInterceptor.java
public String intercept(ActionInvocation actionInvocation) throws Exception {
System.out.println("拦截器初始化...");
ActionContext ctx = ActionContext.getContext();
Map session = ctx.getSession(); // sessionStudent
if (session.get("username") == null) {
return "login";
}
String result = actionInvocation.invoke();
return result;
}
struts.xml
<!--继承的是json-default -->
<package name="struts2" namespace="/" extends="json-default">
<interceptors>
<interceptor name="configInterceptor"
class="UserInterceptor">
</interceptor>
<interceptor-stack name="myStack">
<interceptor-ref name="configInterceptor"></interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
</interceptor-stack>
</interceptors>
<interceptor-ref name="myStack"></interceptor-ref>
<default-interceptor-ref name="myStack"></default-interceptor-ref>
<global-results>
<result name="login">/login.jsp</result>
</global-results>
哪位大侠帮帮忙啊