在实际开发中,ExecuteAndWaitInterceptor很适合在后台长时间运行的action时,他可以可为用户一个友好的等待界面,例如进度条。
1.struts.xml配置,加上两个拦截器,wait表示等待的界面
2.ognlAction :(Thread.sleep(20000))
3.wait.jsp:红色地方表示加载的时间和加载的地址
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = .getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'wait.jsp' starting page</title>
<meta http-equiv="refresh" content="5;url=<s:url includeParam="all" />"/>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
等待界面
<a href="<s:url includeParams="all" />">click</a> 页面没跳转单击这
</body>
</html>
界面截图: