Wait拦截器(execAndWait)友好提示

前台表单提交登录请求(login.jsp, login.action,wait.jsp)

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>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值