【问题标题】:How to know that http redirect + form POST is successful如何知道http重定向+表单POST成功
【发布时间】:2020-05-14 17:33:35
【问题描述】:

我的 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 中

非常感谢。

【问题讨论】:

    标签: http http-post wildfly wicket http-redirect


    【解决方案1】:

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

    【讨论】:

    • 感谢您的回答。该应用程序是无状态的。如何处理自定义 cookie 解决方案?我的 URL 不会向用户显示任何内容。它的唯一目的是触发后端逻辑,然后将用户重定向到目标 URL。
    • POST后在response中写入Cookie,并在负责GET的页面中读取+删除cookie
    猜你喜欢
    • 1970-01-01
    • 2011-08-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多