前台表单提交登录请求(login.jsp, login.action,wait.jsp)
login.jsp
LoginAction正常处理
wait.jsp
struts.xml
login.jsp
<form action="login.action" method="post">
username:<input type="text" name="username"><br>
password:<input type="password" name="password"><br>
<input type="submit" value="submit">
</form>
LoginAction正常处理
wait.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
//当前页面当时刷新3秒
response.setHeader("refresh","3;URL=login.action");
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 'login.jsp' starting page</title>
<!-- 定时刷新3秒,当前页面 -->
<meta http-equiv="refresh" content="3;URL=login.action">
</head>
<body>
<h1>数据已经提交,正在等待服务器返回信息,请耐心等待。。。。。。</h1>
</body>
</html>
struts.xml
<action name="login" class="com.test.action.LoginAction">
<exception-mapping result="usernameInvalid" exception="com.test.exception.UsernameException"></exception-mapping>
<result name="success">/result.jsp</result>
<result name="usernameInvalid">/usernameInvalid.jsp</result>
<!-- 这里的name一定要为wait -->
<result name="wait">/wait.jsp</result>
<interceptor-ref name="defaultStack"></interceptor-ref>
<!-- exec拦截器必须在所有拦截器的最后 -->
<interceptor-ref name="execAndWait"></interceptor-ref>
</action>