当前位置: 代码迷 >> J2EE >> struts2 自定义拦截器 异常信息拦截
  详细解决方案

struts2 自定义拦截器 异常信息拦截

热度:160   发布时间:2016-04-22 02:27:06.0
struts2 自定义拦截器 错误信息拦截
代码如下:
红色字体部分,在跳转前截获拦截的错误信息,怎么实现提示框显示出错误信息后再跳转页面



public String intercept(ActionInvocation invocation) throws Exception {
Object userObj = ActionContext.getContext().getSession().get("users");
if (userObj!=null)
return invocation.invoke();

invocation.getInvocationContext().put("tip", "你还没有登录");
return Action.LOGIN;
}




------解决方案--------------------
将脚本信息直接输出一下啊~~~

response里应该有一个PrintWriter(out)

Java code
out.print("<script type='javascript'>alert('你要输出的信息..');</script>");
  相关解决方案