struts2 extjs json-default 拦截器

昵称都存在了吗? 昵称都存在了吗? 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我做了一个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>

哪位大侠帮帮忙啊

...全文
评论 13
收藏 已收藏
分享
返回顶部
昵称都存在了吗?
Web 开发 81,108 成员 341,721 内容