execAndWait拦截器
来源:互联网 发布:数码宝贝tri5 知乎 编辑:程序博客网 时间:2024/04/30 05:09
由于某个Action要执行较长的时间,所以在切换到下一个有效页面之前。一般先会进入一个等待的页面,等待页面装载。在互联网上这种页面的等待的效果会经常被用到,现在就借用Struts2的拦截器来实现这个功能。 使用到的拦截器为execAndWait拦截器。分析拦截器的源码。
public class ExecuteAndWaitInterceptor extends MethodFilterInterceptor { public static final String WAIT = "wait";
protected String doIntercept(ActionInvocation actionInvocation) throws Exception {/*------*/
return WAIT;
}
}
上面的代码中没有看到Interceptor()方法的实现。所以到父类中看个究竟。
public abstract class MethodFilterInterceptor extends AbstractInterceptor {
@Override
public String intercept(ActionInvocation invocation) throws Exception {
if (applyInterceptor(invocation)) {
return doIntercept(invocation);
}
return invocation.invoke();
}
protected abstract String doIntercept(ActionInvocation invocation) throws Exception;
}
所以只要实现 doIntercept()方法。拦截器执行后会返回WAIT.
execAndWait拦截器的执行过程。execAndWait拦截器能够让一个执行时间较长的Action在后台执行,是通过生成一个单独的线程的形式,单独执行这个时间较长的Action。在Action执行结束之前将放回WAIT结果,WAIT结果同时负责让后续的请求返回到这个Action。在Action结束后返回Action中execute方法返回的字符串,程序继续执行。
所以这样可以实现在一个长时间Action没有完成时,我们可以让页面挺留在一个WAIT页面。
<result name="wait" type="dispatcher">
<param name="location">wait.html</param>
</result>
具体例子见E:\javaEE\Interceptor
- execAndWait拦截器
- struts2的execAndWait拦截器使用
- Struts2 execAndWait拦截器的使用
- Struts2的execAndWait拦截器使用
- struts2的execAndWait拦截器使用
- struts2的execAndWait拦截器使用
- Struts2中execAndWait拦截器的使用
- struts2的execAndWait拦截器使用
- struts2 - execAndWait(拦截器实例)
- 使用execAndWait拦截器模拟进度条 之 19.2.1 模拟长时间
- Struts 2 execAndWait interceptor example
- Struts 2 execAndWait interceptor example
- 拦截器
- 拦截器
- 拦截器
- 拦截器
- 拦截器
- 拦截器
- Ogre 1.8 文件系统部分(Serializer)
- winform中结束程序,SQL空值替换
- Dialog汇总
- java学习笔记:声明方法时加入可变参数
- javascript例子
- execAndWait拦截器
- 单链表2
- VC中利用多线程技术实现线程之间的通信
- 特性
- HTTP请求
- USB的挂起和唤醒 (Suspend and Resume)
- vector用法 (二) 迭代器
- PHP字符串处理相关函数
- J2EE WEB应用架构发展分析