首页 > 解决方案 > 如何知道http重定向+表单POST成功

问题描述

我的 wicket Web 应用程序正在执行表单 POST + 重定向到给定 URL。这旨在将用户重定向到该 URL,并在托管该 URL 的服务器上发布信息。是否有任何解决方案可以知道重定向成功或失败。关键是,一旦我们进行重定向,我们不知道用户是否看到了目标网页。下面是执行重定向的网页

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <title>Redirection Page</title>       
    </head>
    <body>
        <div style="display: hidden;">
            <form wicket:id="customerForm" id="redirectForm"  method="post">
                <input wicket:id="param1" type="hidden"/>
                <input wicket:id="param2" type="hidden"/>
                <input wicket:id="param3" type="hidden"/>
             </form>
           <script language="javascript">
                document.getElementById("redirectForm").submit();
            </script>
        </div>
    </body>
</html>

Web 应用程序使用 wicket 6.27.0 和 JEE7 开发,并托管在 Wildfly 10 中

非常感谢。

标签: httphttp-postwildflywickethttp-redirect

解决方案


您可以在 MyForm#onSubmit() 中的 Session 中存储一个标志,并在 GET 端点中读取+删除它。如果您的应用程序是无状态的,那么您可以使用自定义 cookie。


推荐阅读