首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

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

2012-01-19 
struts2 自定义拦截器 错误信息拦截代码如下:红色字体部分,在跳转前截获拦截的错误信息,怎么实现提示框显

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>"); 

热点排行