日期:2014-05-17  浏览次数:20849 次

struts2 拦截器不跳转 求救 在线等
拦截器验证通过没问题,但是失败的时候想跳转到另一个页面,如登录或错误页面,这样它就不跳了, 如果失败了 System.out.println("tip="+ctx.get("tip")); 这个都可以输出出来 ,到执行return 的时候就停了。大家看看哪里错了
拦截器:

public String intercept(ActionInvocation invocation) throws Exception {
 
//没有登陆,将服务器提示设置成一个HttpServletRequest属性  
ctx.put("tip","您没有权限进行本次操作");  
 
//invocation.invoke();  

System.out.println("tip="+ctx.get("tip"));  
return "message";  

}
配置文件:
  <interceptors>
<!--自定义拦截器 -->
<interceptor name="permission" class="com.mengfang.interceptor.permissionInterceptor"/>
<!-- 拦截器栈 -->
<interceptor-stack name="permissionStack">
<interceptor-ref name="defaultStack"/>
<interceptor-ref name="permission"/>
</interceptor-stack>
</interceptors>
<!-- 拦截所有action 如果在引用自定义拦截器它会失去效果,要想引用就得引用两个
<interceptor-ref name="defaultStack"/>
<interceptor-ref name="permission"/> -->
<default-interceptor-ref name="permissionStack"/>
<default-action-ref name="index"/>

<global-results>
<result name="message" >/message.jsp</result>
</global-results>


------解决方案--------------------
探讨

引用:
result返回类型问题?


有什么问题吗? String “message”

------解决方案--------------------
//invocation.invoke(); 被你注释了吧。